kortoom Posted September 30, 2009 Share Posted September 30, 2009 When a user subscribes to my site I create a random identifier with md5. I put this identifier in an email to the user and in a cookie on their machine. When they get the email and click on the link, the identifier (and their email address) is in the URL. They land on the page whose code is below. This code gets the information from the URL just fine. But I can not get $_COOKIE to work at all, even though the cookie is right there, with the identifier in it. I am missing something that enables the landing page to read a cookie that is already there in the browser's cookie directory. I truly appreciate your help with what must be a simple error!!! <?php //first get the email address from the email url -- this works $fans_email=$_GET['email']; //next get the identifier from the email url -- this works $fans_id=trim($_GET['id']); //next get the identifier from the cookie -- this fails $cookie_id=trim($_COOKIE['subttih']); // if the ids match, confirm and continue, if they don't, ask user to retry -- this always fails since there's no cookie value if ($fans_id=$cookie_id) { Header("Location:http://www.tothinkishuman.com/confirm-ok.php?email=$fans_email"); } else { Header("Location:http://www.tothinkishuman.com/confirm-ko.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176083-_cookie-does-not-read-existing-cookie/ Share on other sites More sharing options...
RussellReal Posted September 30, 2009 Share Posted September 30, 2009 no no no -.- use something like md5($email.'2762@uya7s'.$password.'876aiuyas'); and just use that again from the database info and compare it to the md5 sentback in GET from the email Quote Link to comment https://forums.phpfreaks.com/topic/176083-_cookie-does-not-read-existing-cookie/#findComment-927824 Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2009 Share Posted September 30, 2009 So, what values do you use in setcookie() for the PATH and DOMAIN parameters and what if anything is different between the PATH and DOMAIN of the page where the cookie is set and the code you posted? You should actually store the unique id on the server and associate it with the email address because as soon as someone looks at the cookie and the link they will notice that they can create an account on your site by simply putting the same value into their cookie and into the link when their bot script visits your site. Quote Link to comment https://forums.phpfreaks.com/topic/176083-_cookie-does-not-read-existing-cookie/#findComment-927826 Share on other sites More sharing options...
kortoom Posted September 30, 2009 Author Share Posted September 30, 2009 THANK YOU BOTH! RusselReal & PFMaBiSmAd, avoiding the cookie altogether and using the db was the solution I implemented PFMaBiSmAd, the PATH and DOMAIN parameters ought to have been the same, but since I don't actually know that they were, this insight would probably have led to a solution of the cookie issue. BLESSINGS!! Quote Link to comment https://forums.phpfreaks.com/topic/176083-_cookie-does-not-read-existing-cookie/#findComment-927898 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.