1

I am getting a session timeout all the time.

When ever a user is idle for some time, he has to re-login. I want him to login again only if he closes his browser. I have not used anything to destroy or unset the session, I only do that in the logout page.

I have set my PHP INI file to set all the session variables. You can browse the Session Variable here at the link.

http://www.providentfeed.com/phpinfo.php

hakre
  • 193,403
  • 52
  • 435
  • 836
kakaajee
  • 227
  • 1
  • 9
  • 20
  • Possibly a duplicate of http://stackoverflow.com/questions/5577106/what-php-ini-settings-are-required-to-allow-a-session-to-remain-active-for-approx – GordonM Apr 17 '11 at 10:35
  • Thanks Gordon for your directions, but I already have set these two parameters(session.cookie_lifetime and session.gc_maxlifetime) to 40 hours. But it is not working. – kakaajee Apr 17 '11 at 13:03

2 Answers2

6

you can write the following code in your php file.

// Session timeout value in seconds. Let's say we increase it to 24 hours
ini_set('session.gc_maxlifetime', 24*60*60);
Alex
  • 7,538
  • 23
  • 84
  • 152
Naveed Ahmad
  • 3,176
  • 1
  • 15
  • 18
  • Naveed thank you for your reply. Actually I tried this before in my PHP code, it did not worked. Then I tried it in PHP.ini file. Still the same issue. – kakaajee Apr 17 '11 at 13:09
1

That's standard behavior. If you want the user to be logged in indefinitely, you'll need to create a cookie and check for its presence in the login page. And simply log the user in if the cookie exists.

JohnP
  • 49,507
  • 13
  • 108
  • 140
  • Actually it is a big application and not using some MVC so that I can do it easily. I think there will be some solution to keep the session for a couple of hours. Thanks – kakaajee Apr 17 '11 at 13:07