PHP session lifetime problem -


I am using PHP5 here I have created a login system which checks the username and password against the records in the database Does. I want to use the session to store the logged value. For example, when I reach the area where I "login" the user:

  if ($ errors = 0) {$ _SESSION ['log'] = "1" ; }  

The problem is that I want to be active for 5 minutes, when I do a , for the $ _ session ['log'] ($ _SESSION ['Log'] == "1") Also, after this false refund, I would like to delete this session after the user closes the browser. Actually, I want a session configuration so that the user can safely leave his desk and when he refreshes after 10 minutes or after the browser closes again, the session is already deleted, And entry can be restricted

Can anyone help? Thank you. Use

Note that by default, this Is set to 0 , which means that the cookie is set as long as the user does not exit the browser. You can do it in the following way:

  / * Set to 0 if you want to set session cookies, until the user closes the browser. Otherwise use the time () + seconds * / Session_set_cookie_params (0); Session_start ();  

Then check past activity times when someone updates to a page and updates.

  if (($ _ session ['last'] (time ()) {// timed out, destroy session session_destroy (); not set ($ _ session); die ('Time is up!') And {$ _SESSION ['last activity'] = time ();}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -