Logging users in

 
  • Logging users in

    Hey,
    I'm new to the last.fm API. I've been playing around for a few users now and I wondered how can I let users skip the 'allow application' once they allowed it.
    So the first time they are redirected to the last.fm/auth url to grant my application access. When they come back another time, I just want to log them in without the hassle of going to last.fm/auth again.

    It's a web application, using PHP and cURL.
    The documentation says that the session keys generated are valid forever...

    Thanks in advance!

    Ken

    • tburny disse...
    • Forum Moderator
    • Abr 10 2012, 11h52
    You have to store the session key someewhere, either attached to a server-side session object or as a cookie on the client side

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
  • Yes, but when i store the session key and the users clicks 'log in' he will be directed to the last.fm API to get the token right?
    because i can never know which users is trying to sign in.

    Or I can add the session key to the cookie, but that means they never have to login again (unless the cookie/session is removed/destroyed)

    Is this correct?

    Thanks for your reply btw, really appreciate it!

    • tburny disse...
    • Forum Moderator
    • Abr 11 2012, 21h22
    The solution is more the second one. If the cookie expires OR the user cleans all his cookies, then he/she would have to log in again.

    The better solution could be to have a database-backed session storage on the server side. The client side then only gets an identifier cookie (session cookie from your server). Then on the server side you could use that identifier to load arbitary information about that user, like a session key, a username, whatsoever.

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
Usuários anônimos não podem postar mensagens. É preciso fazer login ou criar uma conta para postar nos fóruns.