Jump to content

Cookie Confusion


sonicphc

Recommended Posts

Maybe I'm missing something really obvious here, but today my site while I was working on it decided that it would no longer log people in and out. I worked out that it is not setting cookies anymore. The problematic piece of code is here:

 

setcookie("logid", $user['id'], time()+400000, "/", ".chaossector.com");

echo "ok";

 

It's called via AJAX and is set that if it doesn't return "OK" to flag an error. It's not flagging an error, and is more or less behaving like the "setcookie" call doesn't exist. I can set cookies all I want via javascript, but PHP just isn't working.

 

I also tried the following after manually setting the logid cookie through javascript:

 

setcookie("logid", "", time()-400000, "/", ".chaossector.com");

echo $_COOKIE['logid'];

 

and it keeps returning the value I set it to every time. When I go to check if the cookie has been deleted, firefox says the cookie is still there.

 

I just can't seem to fathom why it is completely ignoring any calls to setcookie when it was working just fine yesterday. Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/112860-cookie-confusion/
Share on other sites

I decided to go back to basics and try a simple call of setcookie

 

<?php

    $name = "moose";

    $value = "alsowik";

    setcookie($name, $value, time()+(60*60*24*365), '/', '.chaossector.com');

?>

 

And still nothing. No cookie, and also no errors. As there something wrong with my call to setcookie here?

Link to comment
https://forums.phpfreaks.com/topic/112860-cookie-confusion/#findComment-579690
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.