Posted: March 11th, 2008 @ 01:27pm
Sessionless Sessions
A little while ago I mentioned in a post on the PHP-General mailing list that I’d implemented a way to persist data between page requests without requiring server-side storage. This raised a number of questions which I answered without giving too much away.
A few weeks later Jochem Maas asked for a more detailed explanation. I had already started writing an article for this site explaining the details but since it’s a low priority I hadn’t finished it yet. I have now.
Sessionless Sessions is a somewhat confusing title but I hope I’ve explained what I mean clearly within the article As always comments are welcome.
PHP Encoder said...
Thanks for this article.
Can’t you just store sessions in mysql DB and solve all issues caused by file-based sessions?
Stut said...
Yes you can but on high-traffic applications this can lead to database requests that aren’t necessary which will eventually lead to further scaling issues. Essentially you’re just shifting and delaying the problem.
Also consider that when using traditional sessions you’re probably reading the session data on every request even if you won’t be using/updating it. In the article I described a method of securely storing a limited amount of data between page requests that requires very little extra processing per request and does not involve server-side storage thus eliminating any scaling issues.
Thanks for your comment and I’m glad you enjoyed the article.