The Quest to Conquer the PHP Session Timeout

Saturday, June 14. 2008


PHP sessions are handy little things, however it's a bit tricky to correctly get a custom timeout to work correctly. There are a few key ini settings:

session.gc_maxlifetime -This setting (in seconds) tells the PHP garbage collector how long to keep the session valid.  The default is 24 minutes.

session.gc_probability - The probability that the garbage collector will run and clean up old session data.  The default value is 1.

session.gc_divisor - The divisor to use with the probability.  The default value is 100.

session.save_path - The path for session values to be saved.  The default is /tmp, however it is important to change this to a custom folder for the application - especially if you are in a shared hosting enviorment.  The garbage collector does not discriminate, and it will delete ANY session data that is older than the set limit, not just ones that correspond to your application.

session.cookie_lifetime - How long to keep the cookie written to the client machine valid.  Defaults to 0, which means the cookie will expire at the end of the broswer session (at logout or when closing the broswer).

Now, before you start anything, make sure you have a writable folder setup for your application that you can use to store your session data.

Start your session with something smiliar to:

ini_set('session.gc_maxlifetime', '86400');
ini_set('session.gc_divisor', '1');
ini_set('session.gc_probability', '1');
ini_set('session.cookie_lifetime', '0');
ini_set('session.save_path', /path/to/sessions/myapp);
session_name('myapp');
session_start();

Setting the above configuration well make sure your session files are saveed in a seperate folder, they will expire in 24 hours, and the garbage collector will run everytime session_start is called to cleanup expired sessions.

The problem with alot of other infomormation is that they will suggest setting the cookie_lifetime to be the same as the gc_maxlifetime.  The problem with this is that when the cookie value is set, the expiration date is not updated as the user continues to be active in the application.  The session data on the server side is updated.  So, if this is the case, after the value of cookie_lifetime has expired, even if the session data on the server was just updated, your session will be invalid, and you will be required to login again.

I hope that this post will help someone else in the quest to conquer the php session timeout.  It definitely is not very clear, and can be very confusing!

The Landlord

Tuesday, May 22. 2007

So, today my landlord (who's name I will not mention) decided it would be a good idea to re-key the outside doors to my building.  I don't know about you, but after getting home from a long day a work, the last thing you want to do is figure out why you can't get into your building.  So, I called the main office, and they informed me that I received a note yesterday (which there was no trace off).  After a few minutes of bitching them out about their lack of notice, and failure to inform tenates and post signs, I walked over to get a new key.  Needless to say, now they have posted signs saying they have re-keyed the building.

Maybe I should send Pearl to talk some sense into my landlord :-)

International Dinner 07

Sunday, April 22. 2007

Friday night Sami talked me into going to the International Dinner on campus. For $10 for students, $16 for everyone else you get to try a wide variety of dishes from different countries. Even though the food was prepared by Chartwells, it was still pretty good. The menu was as follows:

Salad:

  • Tunisian Couscous Salad - North Africa
  • Baba Ganouj (roasted eggplant dip) - Middle East
  • Kim Chi (fermented cabbage) - Korea

Entree:

  • Pork with Dumplings & Cabbage - Czech Republic
  • Pad Thai (meatless) - Thailand
  • Hungarian Chicken Paprika - Hungary

Side Dish:

  • Cauliflower Curry - Nepal
  • Jamaican Rice with Peas - Jamaica
  • Lecso (simmered peppers & tomatoes) - Hungary

Dessert:

  • Conconut Toto - Jamaica
  • Apple Strudel - Czech Republic

As you can see, its quite the variety. Every got a recipe book as well. Any bets what I'll make first?




It's mid April already?

Sunday, April 15. 2007

Well its been quite a while since I posted anything here, so I figured it's time to post a little update. As usual, I've been pretty busy with work and such. This last weekend was more eventful than most.

Friday Mr. Nolan decided to grace whitewater with his presence. After minor begging, i was persuaded to go out for a bit and get jumped on by Mr Snieg. Does anyone really know why Snieg is a jumper? I think its somehow related to the genetics of the Monguin gene.

Saturday start out with a great nights sleep, followed up by 2 naps! (Can't go wrong there). That evening I ventured to Elkhorn where Paul, Michelle, Dohr and myself went out to dinner at Popeye's in Lake Geneva. It was my first time there, very tasty. After dinner we tormented Sadie with the woot screaming monkey!

Today I decided to invest in a Wireless Cell Phone Extender, I'm curious to see if it actually works. If it doesn't, at least there is a 30 day guarantee. I also decided to purchase an I-Pass, I've had enough of the Illinois tolls!

Well, thats about it for my excitement. Until next time, keep your stick on the ice!


PS. Does anyone know what that phrase is from? :-)

Random Crap!

Monday, April 9. 2007

My random crap came today. Inside I was graced with the following items:

  • 1 - Screaming Flying Monkey w/Woot Cape
  • 1 - Targus Travel bag
  • 1 - Texas Holdem Electronic Game
  • 1 - Barbie Phone

Don't believe me? See for yourself:




Check out the gallery for more pictures: Fools Crap

3 Craps!

Saturday, March 31. 2007

Finally, after years (literally) of attempting to get a bag of crap, I got 3! It just took a tricky April Fool's Day woot!


PS: It really only cost $6, there was a coupon code.

T-Mobile Caller ID

Monday, February 12. 2007


Ever wondered how to get your name to show up when you call a land line from your cell phone? Apparently, you can just give T-Mobile Customer Care a call and they can set the text which appears individually for each line. There is about a 24 hour processing time for the change to take place, but nonetheless, its a pointless cool feature. So, hopefully in 24 hours my name is no longer "Cell Phone WI".

Winter is Here

Sunday, February 4. 2007


Today, the current temperates around Wisconsin are the same (or colder) than areas of Alaska, is it just me, or does that sound a little nuts? It's been a busy past month with things happening at work at UW-Whitewater and also with Modevia. We finally go the new Modevia website launched - www.modevia.com - check it out! The new support center is hopefully right around the corner as well!

I also recently aquired a new domain name which I have moved my personal email address - aaron at axelsen dot us. Hopefully in the new future, i'll also launch a website there as well. Check back in the future for updates!

That's all for now, stay warm!

HP Officejet G85 for Sale

Monday, January 1. 2007


I have an OfficeJet G85 Scanner/Printer/Copier/Fax for sale. It work's fine, has black ink (needs a new color cartridge), and comes with a 15 foot usb cable. If anyone is interested, let me know!


Happy Turkey Day!

Thursday, November 23. 2006

So apparently everyone on the roads yesterday thought that we were in Germany.  I made the 240 mile trip home in 2 hours and 45 minutes, reaching a top speed of about 100mph.  And to top it all off, I somehow managed to average 40mpg.  Gotta love the diesels!

Anyways, I hope everyone has a great thanksgiving!

Does anybody really read this?

Wednesday, October 11. 2006

I got to thinking and was wondering if anyone really does read my blog.  If you do, leave a comment.

Weekend Up North

Tuesday, October 3. 2006


I never remember how amazing the fall colors are until you actually see them. This last weekend Katie and myself made the trek up to Menomonie for my neighbors wedding. It was a nice wedding, and a tasty reception. We also concluded that all we did was eat. Friday night we went out for fish fry at Whitetail (a golf course in the area). Saturday we went out to lunch with my Godmother to The Creamery Resturant and Inn for a tasty meal. Saturday afternoon we attended the wedding, and then went to the reception for some tasty eats. Sunday, we woke up and had eggs and bacon. We then took a trek up to Otter Creek to the cabin to see some colors (Check out the gallery, amazing pictures). When we got back, we ate again and then left.

Anyways, it was a fun weekend, and the best part was .. WE HAD CELL RECEPTION!


GSM Cell Wars

Monday, September 25. 2006


So, for about the last week and a half Katie and I have had very sketchy cell phone coverage in Whitewater. We called T-Mobile and first they told us to call Cingular (we roam on Cingular towers in whitewater). Of course, Cingular refused to talk to us because we aren’t their customers, they informed us T-Mobile has to contact Cingular and work with them directly to solve the issues. We called T-Mobile back, they and they filed a ticket. After a few days of hearing nothing, I decided we needed to determine what cell tower was causing us problems. After visiting cellreception.com, I plotted all the cell towers in the area out on Lucy, and we (Katie and I) headed for the car to take a tour around and figure out what was going on. After about an hour of driving around, we determined what I had thought. The tower on Winther Hall apparently doesn’t play nice with T-Mobile. So, I then thought I’d call T-Mobile and have them add this information to the ticket in hopes that it may help out the engineers some.

Today, Mike called up T-Mobile, and they told him they closed the first ticket, opened a ticket at a higher level, they then closed that ticket and opened a ticket at OSD. Mike also informed me that they did a site survey of the area and submitted a proposal for a new tower in this location. Cross your fingers, maybe they will put one up! Until then, it’s the joys of sporadic cell service so if you call and get voicemail right away or after a couple rings, that’s why.

~ Receptionless in Whitewater

AK Roadtrip Conclusion

Tuesday, August 29. 2006

Like everything in the world, all good things come to an end. So, the road trip was a great success. It was so much fun and will definitely live on in all the great memories. We saw Niagara Falls which was an amazing site to see, I definitely recommend it for anyone who hasn’t been there.

We also made a stop in Boston. I got a personalized tour from Katie on some of the key and cool parts of Boston. I’ll definitely have to go back sometime and check out some more of it.

We then made our way to Virginia to Mikes. This was our first real downtime of the trip since we stayed there for a few days and relaxed by the pool, and took the Metro into DC to do some sightseeing and wander around. It was a very cool place to go, but I think we will always wonder if we were suppose to just be wandering around outside the pentagon :-).

Katie did all the driving, so it really was a vacation for me, I just sat back and yelled at Lucy. Thanks to Katie for coming with, it really was a great trip and vacation and we will have to do it again.

Next road trip destination: Oklahoma!

Aaron and Katie Roadtrip Video Recap

Tuesday, August 29. 2006

Here is the full collection of videos from the roadtrip:

Niagara Falls Fireworks 1

Maid of the Mist 1 2

Niagara Falls 1

Washington DC Nightlife 1 2 3 4

Sibu - What a night 1 2

Aaron Kills Cricket 1