Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.