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?

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.