limitphp Posted November 3, 2008 Share Posted November 3, 2008 I set a cookie with this: setcookie("nwo",$tempID, time()+3600*24*365); When I check if the cookie is set with this: if (isset($_COOKIE['nwo'])) { } how do i check the expirationDate? thanks, php 5.2.6 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 3, 2008 Share Posted November 3, 2008 You cannot. The browser only sends the cookie name and value to the web server. What are you trying to accomplish? Quote Link to comment Share on other sites More sharing options...
limitphp Posted November 3, 2008 Author Share Posted November 3, 2008 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? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 3, 2008 Share Posted November 3, 2008 Yes if the cookie is present, it's valid. Once it expires, it is removed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.