3

I am developing a simple php website named : http://www.dopanchat.com

In this site I used session to develop the login system, everything work fine but after some amount of time (for example, after 1 hour) the session expires automatically and user logged out from my site.

I don't know if it's server problem or anything else.

please help me to resolve this problem, you can check here : http://www.dopanchat.com

Ali
  • 2,993
  • 3
  • 19
  • 42
  • possible duplicate of ["Keep Me Logged In" - the best approach](http://stackoverflow.com/questions/1354999/keep-me-logged-in-the-best-approach) – Alessandro Da Rugna Jun 30 '15 at 08:46
  • 1
    Use cookie for managing user session for long enough for a day or more – Meenesh Jain Jun 30 '15 at 08:46
  • @MeeneshJain, another approach, but its good idea when you want to let the user login back automatically _(e.i. remember me)_ – Ali Jun 30 '15 at 09:17

3 Answers3

2

Extending your session timeout is an approach but I won't recommend to expand it too much :)

Instead your application could detect user activities and refresh the session expiry time accordingly.

After all it doesn't really matter what is the session's timeout at some point user will lose the authentication due to the expired session.

Basically the expiry count down always starts after user's last action and not from the moment s/he logged in to your system.

Ali
  • 2,993
  • 3
  • 19
  • 42
0

you can extend session expire time by adjusting php.ini file as follows

session.gc_maxlifetime=86400 //1 day
session.gc_divisor=5000
session.gc_probability=1

gc_divisor and gc_probability are responsible for cleaning expired session files, by above config session will valid for 1 day

user1844933
  • 3,296
  • 2
  • 25
  • 42
0

Try this :

// Time in secondes before the session expires
ini_set('session.gc_maxlifetime', 3600);

// Time in secondes before the ID's session in the cookie expires
session_set_cookie_params(3600);

// Start session
session_start();

If think this gonna work. Tell me if it work !

(Sorry for my bad english :D)

SatanicGeek
  • 342
  • 5
  • 15