Cookies and sometimes sessions disappear on subdomain |
I am using Codeigniter to create a website that works with different subdomains. Each customer gets his own subdomain and can log in from there.
for instance: customer1.domain.com customer2.domain.com The problem is that cookies regularly disappear after logging in at a subdomain, sometimes immediately after refreshing the page. Sometimes after opening a different page but sometimes also after some minutes. Meanwhile I have tried different things but I can't find the problem. It happens both when I use the cookie helper of codeigniter and the standard php cookie methods. I tried the following for cookies: PHP Code: $rootdomain = '.domain.nl'; and the PHP method: PHP Code: setcookie("session_hash", $session_hash, time() + 86400,'/',$_SERVER['SERVER_NAME']); For the sessions I use the standard PHP method like: PHP Code: $_SESSION['session_hash'] = $session_hash; So I tried to set a session hash cookie and session for back-up, but the cookie and the session disappear. is there anyone who can tell me what I'm doing wrong? If I use the same functions without a subdomain, it works fine.
1) Sometimes you need to add a period ( . ) to the beginning of the domain name.
2) Make sure that your cookie & session expire time is set correctly. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |