0
<?php



if (isset($_POST['user_id'])) {
// Not logged in :(

    setcookie("secondcookie[id]",$_POST['user_id'], time() * 7200, "/"); // Expiring after 2 hours
    setcookie("secondcookie[password]", $_POST['user_pass'], time() * 7200, "/");


    //when to see if cookies is set or not

echo $_COOKIE["secondcookie"]["id"]; 


    //header("Location:verification_data.php"); 


}

if (isset($_COOKIE['secondcookie']['id'])){
 // Already Logged in go to page 3
 header("Location:page3.php"); 
}

 ?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MASTERS THESIS PROJECT</title>
</head>

<body  >
<form name="login_form" method="post" >

<center>
<img src="img1.jpg" width="1300"  />

<br />
<br />
<br />
<br />

<table border="4" bgcolor="#CCCCCC">
<tr><th colspan="2">MEMBER LOGIN</th></tr>
<tr>
<td>USER ID :</td> <td><input type="text" name="user_id" id="user_id"  /></td>
</tr>
<tr>
<td>USER PASSWORD :</td><td><input type="password" name="user_pass" id="user_pass"   /></td>
</tr>

<tr><td colspan="2" align="center"><input type="submit" value="login" name="login"  /><input type="reset" value="reset" name="reset"  /> </td></tr>
<tr><td colspan="2" align="center"><a href="page5.php">create a new account here</a></td></tr>

</table>
</center>
</form>
</body>
</html>
2
Contributors
2
Replies
9
Views
2 Years
Discussion Span
Last Post by soomro_moon
0

The problem should be with the time you've set..

If you want the cookie to expire in 2 hours you should set it to time() + 7200, instead of time() * 7200..

It should be the time() plus the [no. of seconds]..

Edited by iMadhusanka: added some missing clarification..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.