Hey Friends, Today I am going to describe the PHP Code regarding automatic expire session login in a website. It is very easy to expire session for login for sometime or specified time.
$_SESSION['timestamp']=time();
| <?php | |||
| //on pageload |
| session_start(); |
| $idletime=60;//after 60 seconds the user gets logged out |
| if (time()-$_SESSION['timestamp']>$idletime){ |
| session_destroy(); |
| session_unset(); |
| }else{ |
| $_SESSION['timestamp']=time(); |
| } |
| //on session creation |
No comments:
Post a Comment