Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Session Expiration - When does it refresh?

I'm using Zend with a session expiration set to 1,800 seconds. I was wondering if this session expiration time refreshes back to 1,800 seconds every time I make a request from the browser to the server on behalf of the user and also when the user loads a new page, or does it just refresh when the user loads a new page?

like image 376
Braydon Batungbacal Avatar asked Nov 04 '22 23:11

Braydon Batungbacal


1 Answers

When a user loads a new page, that is the browser making a request to the server on behalf of the user. So the two scenarios you painted above are the same thing.

When a session is started, the session ID is sent to the browser which usually stores it in a cookie. The browser then uses the cookie to pass the session ID to the server with each request to identify the user. The server keeps track of when the session expires and this area can get a little tricky (read How do I expire a PHP session after 30 minutes?)

But as long as you are using the same browser to make the requests, then the session expiration will refresh in the two scenarios you've given.

like image 145
antony Avatar answered Nov 09 '22 15:11

antony