Jump to content

Setting a cookie?


Recommended Posts

This is the first I've tried using cookies for a website. The below isn't setting a cookie.

 

I have my log-in form on the home page. Which submits to this script "login.php", if the credentials match the database, then it redirects to index.php?home. On ?home I'm trying to echo out the cookies and they're coming up blank. I also checked the cookies set in my browser, and the only one set for this domain name is the PHPSESSID.

 

 

The $login_stay_logged_in variable is set and it does = yes.

if($login_stay_logged_in=="yes"){
$hased_value = kam3(md5(generatepassword()));
$hashed_username = md5s($rows["email_address"]);
$time = time();
setcookie("emtco_hash", $hased_value, time()+(86400*180), "/", "beta.area51entertainment.com");
setcookie("emtco_username", $hased_username, time()+(86400*180), "/", "beta.area51entertainment.com");
setcookie("emtco_visited", $time, time()+(86400*180), "/", "beta.area51entertainment.com");
}

 

 

if(isset($_GET['home'])){
$content.='
<div class="left"></div>
<div class="center">'.$_SESSION['username'].'<br /> '.$_SESSION['password'].'<br /> '.$_SESSION['login_stay_logged_in'].'
<br />'.$_COOKIE["emtco_hash"].'
<br />'.$_COOKIE["emtco_username"].'
<br />'.$_COOKIE["emtco_visited"].'</div>
<div class="right"></div>
';
}

Link to comment
https://forums.phpfreaks.com/topic/263638-setting-a-cookie/
Share on other sites

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.