Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I thought the whole point of sessions was to authenticate users. </p> </blockquote> <p>No, sessions are used to identify requests that belong to the same browser. It does not identify or authenticate users. This is the job of your code. Sessions usually work via Cookies: on first request servers sends a cookie, then on all subsequent requests browser adds cookie to the request. That's how server knows that a series of requests belong to the same client (browser). For this to work in your case, your <a href="https://stackoverflow.com/questions/3587254/how-do-i-manage-cookies-with-httpclient-in-android-and-or-java">Android code should use cookies</a>.</p> <blockquote> <p>Isn't there supposed to be some id?</p> </blockquote> <p>Yes, after login you'd normally get some user ID, but this is specific to login procedure. Also this has nothing to do with sessions. Session is basically an object on the server side that is always the same when requests come from the same client. You can store some attributes into the session object: normally after user performs login, you'd store their user ID into session to easier identify requests coming from the same user. When user logouts, you'd delete the user ID from session.</p> <blockquote> <p>What do I send back to the client after a successful login?</p> </blockquote> <p>Enable sessions on server (= <a href="https://github.com/dound/gae-sessions/wiki/comparison-with-alternative-libraries" rel="nofollow noreferrer">pick your library</a>) and <a href="https://stackoverflow.com/questions/3587254/how-do-i-manage-cookies-with-httpclient-in-android-and-or-java">enable cookies in Android code</a>. Then sessions will be automatically handled between your client and server. After successful login just store user ID into session. On subsequent requests just check if session contains user UD.</p> <blockquote> <p>How does get_current_session know who the user is?</p> </blockquote> <p>It doesn't. After login you store some user-related data into session and on subsequent requests you can check for this data.</p> <blockquote> <p>What does the client send to the server with every request?</p> </blockquote> <p>For sessions to work it should send a cookie. This is done automatically if you enable cookie support in Android HttpClient code (link above).</p> <blockquote> <p>What if the user is signed in from multiple devices?</p> </blockquote> <p>Multiple clients would result in multiple independent sessions. It's up to your server code to identify sessions that belong to same user (= multiple sessions would have same User ID stored in them). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload