Jump to content

Cant get Cookie!


rondog

Recommended Posts

I am able to set the cookie just fine as I can see it in my cookie list in firefox with the correct values, however I cant seem to get the cookie. Here is my code:

<?php
$user = $_COOKIE["fd_mem_user"]; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/swfobject.js" type="text/javascript"></script>
</head>
<body bgcolor="#333333">
<div align="center" id="loginsys">
  <script type="text/javascript">
        // <![CDATA[
        var so = new SWFObject("membership.swf", "membership", "590", "300", "9", "#333333");
	//so.addParam("allowScriptAccess", "always");
	so.addVariable("usercookie","<?php echo $user; ?>");
        so.write("loginsys");
        // ]]>
      </script>
</div>
</body>
</html>

 

I also tried : $user = $HTTP_COOKIE_VARS["fd_mem_user"];

 

Link to comment
https://forums.phpfreaks.com/topic/132597-cant-get-cookie/
Share on other sites

ok I managed to get it working..seems like I had to set a path to "/"

 

I am now having a problem removing the cookie:

if(isset($cookie))
{
setcookie("fd_mem_user",$username, time() + 31536000,'/');
}
else
{
setcookie("fd_mem_user","", time()-3600,'/');
}

 

basically if the check box isnt checked $cookie isnt set so it should set the cookie to "" but its not. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/132597-cant-get-cookie/#findComment-689502
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.