Reputation: 31
The PHP sessions store data on server and fetch the session id from the client machine. The doubt I have been having is that suppose I create a web application where on login the user email id is stored in a session variable. Now if this application is deployed on a common server and when two users login how does the server differentiate the users? Because it's the same session variable which will be used to store their email ids. What procedure avoids the overwriting if it is at all avoided?
Upvotes: 1
Views: 88
Reputation: 1200
SessionID are stored in an HTTP Session cookie (i.e. transient cookies only available during a browser "session", and stored in the memory of the browser); the first time a user displays a page of your web site (without even beeing logged on), a cookie containing a new (and unique) SessionID is generated by the server and sent to the client in this cookie. The client and the server will then communicate during all the session with this cookie added on all messages.
All data you store in the $_SESSION
variable are automagically stored in a separate memory space, depending on the SessionID. In fact, it is mostly like $_SESSION[SessionID]
, but managed transparently by PHP.
You can read more on PHP Session in the PHP doc site
Upvotes: 1