How to add template in codeigniter |how to create template in codeigniter| template in codeigniter 4
Session Automatic Logout If website is in idle, then website will logout.
We set login time in session and when any page will refresh after login then PHP make difference between current time of reloading page and login time i.e stored in session. If the difference will vary more than 5 second then the session will be destroyed.
Example of Auto login session in PHP
Step 1 : Login Page(index.php)
<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 if(isset($_SESSION['loggedAt'])) { header('dashboard.php'); } if(isset($_POST['submit'])) { $name=$_POST['uname']; $pass=$_POST['pass']; if($name=="admin" &amp;amp;&amp;amp; $pass=="1234") { session_Start(); $_SESSION['username']=$name; $_SESSION['loggedAt']=time(); header('location:dashboard.php?msg=Welcome to dashboard'); } } ?-->
Step 2 : Welcome page (dashboard.php)
if(time() - $_SESSION['loggedAt'] > 240) { echo""; unset($_SESSION['username'], $_SESSION['loggedAt']); header("Location: " . index.php); exit; } else { $_SESSION['loggedAt'] = time(); }
I think You will get help in this blog
Thank You
Related posts
Great!! This is good example for create a auto logout user session. It saved lot of time. It just made my work easier. This was so easy to follow and exactly what I was looking for.
Thanks.