shruti A
asked on
Logout session for every 4 hour once
I need to logout for my website so I'm trying logout automatically for every 4 hour once ,i'm not getting how to do so please let me know the solution
how to send session variable from html to php please help me to get solution .
Thank you
<form action="index.php" method="post" name="frm"><input name="uname" type="text" placeholder="User Name" />
<input name="pass" type="password" placeholder="Password" />
<input name="submit" type="submit" value="submit" />
</form>
<?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
$_SESSION['timestamp']=time();
how to send session variable from html to php please help me to get solution .
Thank you
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Create the cookie with an expiry date 4 hours in the future. Send that cookie to the browser
When a user connects - check the cookie - if it exists - all is good - refresh the expiry to 4 hours in the future.
No cookie - then the session has expired.
setcookie()
Open in new window
Login pageOpen in new window