June 1, 200917 yr Hi people, I've just been looking into using sessions instead of cookies to store log-in details and although I haven't had the time to implement a log-in script that uses sessions I'm pretty confidant I understand it. There is just one question, which is pretty much irrelevant in practice but I am interested how the server-side session variables are stored? I know they are in a tmp folder on the server but what format are they stored in, is it a plain text file or something else? Any insight would be great Rich.
June 1, 200917 yr When you start a session, a sessionid is generated for that user and stored in a cookie on the viewers computer. The session data is saved on the server with the name SESS_ + sessionid I found this article, which is a pretty good and should answer some of the questions you have.
June 1, 200917 yr Author When you start a session, a sessionid is generated for that user and stored in a cookie on the viewers computer. The session data is saved on the server with the name SESS_ + sessionid I found this article, which is a pretty good and should answer some of the questions you have. I see so do you know what the contents of the file 'SESS_ + sessionid' is? Does it literally just contain standard php variables?
June 1, 200917 yr I wasn't too sure about that, but I just tried it on localhost. The variables are stored in serialized form, but are plain to read. E.g. I stored $_SESSION['test'] as "MrBrightside" and the contents of the session file are: test|s:12:"MrBrightside"; Apparently it's not standard serialization, so you can't just use unserialize() to read the values of the session file.
June 2, 200917 yr Author Cheers for that, I haven't had the time to test it myself! Obviously its not necessary to know, but is always interesting!
Create an account or sign in to comment