Set session duration to 2 hours
							parent
							
								
									8b91a8ed7f
								
							
						
					
					
						commit
						497ed3c207
					
				|  | @ -1,5 +1,6 @@ | |||
| <?php | ||||
| include 'NoDirectPhpAcess.php'; | ||||
| include 'IsValidSession.php'; | ||||
| ?>
 | ||||
| 
 | ||||
| <?php | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| <?php | ||||
| include 'NoDirectPhpAcess.php'; | ||||
| include 'IsValidSession.php'; | ||||
| ?>
 | ||||
| 
 | ||||
| <?php | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| <?php | ||||
| include 'NoDirectPhpAcess.php'; | ||||
| include 'IsValidSession.php'; | ||||
| ?>
 | ||||
| 
 | ||||
| <?php | ||||
|  |  | |||
|  | @ -1,5 +1,4 @@ | |||
| <?php | ||||
| session_start(); | ||||
| error_reporting(0); | ||||
| date_default_timezone_set('Asia/Shanghai'); | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,10 @@ | |||
| <?php | ||||
|     $currentTime = time(); | ||||
|     if (session_status() == PHP_SESSION_NONE) { | ||||
|         session_start(); | ||||
|      } | ||||
| 
 | ||||
|     if($_SESSION['expire'] != null && $currentTime > $_SESSION['expire']) { | ||||
|         include 'logout.php'; | ||||
|     } | ||||
| ?> 
 | ||||
							
								
								
									
										10
									
								
								Script.php
								
								
								
								
							
							
						
						
									
										10
									
								
								Script.php
								
								
								
								
							|  | @ -75,6 +75,11 @@ if (!empty($_POST["form_signup"])) { | |||
|     $_SESSION['user_email'] = $email; | ||||
|     $_SESSION['user_student_id'] = $student_id; | ||||
| 
 | ||||
|     // set session duration
 | ||||
|     $_SESSION['start'] = time(); | ||||
|     $session_duration = 120; | ||||
|     $_SESSION['expire'] = $_SESSION['start'] + ($session_duration * 60); | ||||
| 
 | ||||
|     // check confirmed password
 | ||||
|     if (strcasecmp($password, $confirmpassword) != 0) { | ||||
|         $_SESSION['info_signup'] = "Password confirmation failed."; | ||||
|  | @ -162,6 +167,11 @@ if (!empty($_POST["frm_login"])) { | |||
|                 $_SESSION['user_type'] = $row['UserType']; | ||||
|                 $_SESSION['user_fullname'] = $row['Full_Name']; | ||||
| 
 | ||||
|                 // set session duration
 | ||||
|                 $_SESSION['start'] = time(); | ||||
|                 $session_duration = 120; | ||||
|                 $_SESSION['expire'] = $_SESSION['start'] + ($session_duration * 60); | ||||
| 
 | ||||
|                 if ($_SESSION['user_type'] == "Student") { | ||||
|                     header("Location: Courses.php"); | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue