PHP Expiration - When is it updated?

I use Zend with a session expiration of up to 1800 seconds. I was wondering if this session end time is updated to 1800 seconds every time I make a request from the browser to the server on behalf of the user, as well as when the user loads a new page or is it just updated when the user loads a new page?

+5
source share
4 answers

When a user loads a new page, that is, a browser executing a request to the server on behalf of the user. Thus, the two scenarios that you drew above are one and the same.

When the session is started, the session identifier is sent to the browser, which usually stores it in a cookie. The browser then uses the cookie to send the session identifier to the server with each request for user identification. The server keeps track of when the session expires, and this area can get a little confused (read How to end a PHP session after 30 minutes? )

But while you use the same browser to execute requests, the expiration of the session will be updated in the two scripts that you specified.

+2
source

A cookie containing the session identifier (and all other cookies coming from the destination server) moves with every request you make to the server, whether it is a page refresh or an ajax call.

, , .

0

. . : PHP 30 ?

0

session_start(), , /tmp cookie , cookie . cookie php 30 .

cookie php.ini ini_set .htacces. session.cookie_lifetime. - cookie ,

Another possible solution is to create a token system for users, for example, you manually send a cookie to a browser that expires in 2 months using a token (a large random key stored in the database table with the user ID field). When the session is unavailable, you check if the cookie exists and you can recreate the login session by manually entering the user using the cookie token.

0
source

All Articles