And five years later

I swear it’s the start of the end. Or at least today.

After having my bike around for one year, I finally realized that the kickstand that was annoying the hell out of me for being too short, could actually be lengthened or shortened by turning the little foot either to the right or the left. Yes. It just took me one year to actually notice the little arrows on the foot of the kickstand.

Anyway, that being done, I finally cracked the session mystery I had pending and I totally forgot about until I was confronted by it through one of our clients.

By default PHP Sessions take about 45 minutes before they expire and you have to log in again. You can tamper with that through the session.gc_maxlifetime setting, but when my website was on a shared server that had never worked out for me and I couldn’t figure out why.
Through this article: PHP Session Lifetime: An Adventure, I was finally able to grasp why. What the php garbage collector does is totally ignore the maxlifetime set by your own site if there is another site using a lower maxlifetime on the same server. The gc will take the lowest maxlifetime and clear away all sessions regardless which website the session is for (I assure you this the condensed and incomprehensible version of the article, please go read the article). What Chris Wage proposes is to use the path variable to set a different path, to avoid the garbage collector to wipe your sessions too early. So I tried and after some tests on our development server, I was finally able to confirm what the writer was talking about AND fix my client’s problem.

I thought I’d share since I stumped on this problem a few years back and was quite happy to find a solution when I looked around the docs and the web this time.