Search code examples
phpcookiescolorboxsetcookie

PHP Cookies using in colorbox


I create a cookie in login.php

setcookie("mes_mod_kull",$userid,time() + 3600,'/');

I have a link for open colorbox like this :

<a href="file_add.php" class="colorbox">Add File</a>

In file_add.php I have to use cookie. I mean, I have to reach to cookie which I was created in login.php

I use this code for test cookie value : print $_COOKIE["mes_mod_kull"]; But there is an error here : Notice: Undefined index: mes_mod_kull in..........

Can someone help me ?


Solution

  • The problem is in setcookie function. It's need to define domain.

    I change the following code

    setcookie("mes_mod_kull",$userid,time() + 3600,'/');
    

    to

    setcookie("mes_mod_kull",$userid,time() + 3600,'/','mydomain.com');
    

    and it's worked. It's little bit ridiculous.