I understand the $_SESSION thing and I use it, but what session_id really is and what does it give? I don’t get it, can you give me a hand? Thank you.
I understand the $_SESSION thing and I use it, but what session_id really is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well you need a small lesson on web technology in general.
Protocol we are using, named HTTP, is stateless. Means it never keep track on requests. Even if you click several links on the site, each request would be fresh new, as though there was no previous ones. There is no way to distinguish requests from the same client.
Thus, if we want to distinguish clients, we have to “mark” them somehow. Assign some unique identifier and make them send it with each request. So your session id is that mark. When you start a session for the first time, a cookie is sent along with server’s response. Good client always send all cookies back with every consecutive request. So, we can recognize that client.
Throw in a file on the server side, named after this session id, to store session data – and now you’ve got a session mechanism!