Jump to content

[SOLVED] How to check expired cookie?


limitphp

Recommended Posts

You cannot. The browser only sends the cookie name and value to the web server.

 

What are you trying to accomplish?

 

I'm trying to create a login system where users can select "remember me" and come back to the site without logging in.

So, I set a tempID in the cookie and then put that tempID in a table along with their userID.

Here's my code so far for

if ($mode==1){
$query = "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
$result = mysql_query($query);
$data = mysql_fetch_assoc($result);
$userID = $data['userID'];
$username = $data['username'];
$fname = $data['fname'];
if ($data<>""){
		$loginExist=1;
		$tempID = md5(uniqid(rand(),true));
		setcookie("nwo",$tempID, time()+3600*24*365);
		mysql_query("INSERT INTO tempTable (tempID, userID, expirationDate) 
		VALUES ('$tempID', '$userID', 'time()+3600*24*365')");
	}else{
		$loginExist=0;
	}
}

if (isset($_COOKIE['nwo'])) {

}

 

So, if the cookie is set, then that means it must not be expired?

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.