Solution To Session Timing Out Intermittently

July 21st, 2008 | Save to del.icio.us now(0)

A month back I had written about why your session might not be setting, even though you had set every thing as per the book. This time I am writing about a new problem that I faced with sessions.

The Problem

I recently faced a problem, where for some reason website would not remember session data for some users. They Log in, get to the home page, but the moment they click any other link they are logged out and taken back to login page.

Interesting thing is, this happens for both Firefox and Internet Explorer.

When I used the users credentials I was able to log in perfectly on my machine. When I passed him my credentials to try, and it failed on his machine.

I have faced this problem with both Joomla and Codeigniter framework.

Initially we thought it would be a problem with  just his browser’s cookie setting, so we got him to reduce the web browsers security setting to low, So that it allows for cookie acceptance.  As it turns out, it was not the problem with cookies either.

My Solution

In both (Joomla and Codeigniter) the problem came down to one thing “IP Address”.

We had set for Codeigniter to match the IP address for session requests(it happens by default in Joomla). My stupid assumption was that IP Address will not change between requests, but as it turns out for some of these users, IP address does change in between two requests.

We had used this technique as a way to avoid hackers from hijacking users session.

Anyways the moment we disabled the IP address check, sessions started working for them properly.

So, next time you have a problem with your session breaking in between for no apparent reason, remember to verify IP Address check.

Have you faced this problem? Let us know how did you solve it in comments below.

Related posts

  1. Solution To Session Timing Out Intermittently
  2. Step By Step Guide To Install Memcache On Linux
  3. How to get Latitude/Longitude from an address (or Geocoding ) using PHP
  4. Integrating With Twitter API In CodeIgniter
  5. How to stop regedit, taskmanager or msconfig from closing automatically

Wondering what to do next?


(Search web development related contents)


3 Responses to “Solution To Session Timing Out Intermittently”

  1. April 6, 2009 3:25 pm Jonas says

    Also got problems checking IP in Session, switched to validate User-Agent does not change.
    Not a 100% secure solution but preventing simple hijacking actions.

  2. June 23, 2009 7:18 am Sajin says

    Hi,
    same issue I am facing in joomla. you are right in my case IP is changing, so do you mean I need to remove the IP check in the function. sessionCookieValue or is there any other think I need to do , to make it work.

    Thanks,

  3. January 5, 2010 11:54 am Abhishek says

    Hello ,
    I am also facing same sort of problem but in wordpress blog so i dont know where is ip checking function located in wordpress can ur solution be same for wordpress as itis for joomla. pls reply ASAP

Trackback URI | Comments RSS

Say Something, and Be Counted

Name (required)

Email (required)

Website

Speak your mind