2

I have some codeigniter driven sub-domains and using native codeigniter session library. There is a sub-domain that creates and updates the session and other sub-domain has to share the session. I am not able to share the session among other sub-domains. I have changed the config parameter in application/config.php

$config['cookie_domain']    = "example.com";

but it's not working.

uttam
  • 589
  • 2
  • 7
  • 33
  • try adding "www." in front of the domain. – Taha Paksu Apr 26 '12 at 06:21
  • Direct dupe: http://stackoverflow.com/questions/5783595/codeigniter-session-cookie-domain And after reading comments, still a dupe: http://stackoverflow.com/questions/9881092/subdomain-overwiting-codeigniter-session Please look around before asking questions, a google of "cookie subdomains codeigniter" would have found you loads of examples here and abroad. – lsl Apr 26 '12 at 22:18

2 Answers2

1

Add a dot at the beginning: $config['cookie_domain'] = ".example.com";

Yan Berk
  • 14,328
  • 9
  • 55
  • 52
  • I tried by adding dot at the beginning but it didn't worked. Actually i was using different encryption key for sub-domains. $config['encryption_key'] = "keyvalue"; Corrected the encryption key and solved the problem, anyway thanks for the help... – uttam Apr 26 '12 at 11:14
  • 1
    You should mark this as the correct answer.. because in relation to what you asked, it is. – lsl Apr 26 '12 at 22:17
0

I was facing the same problem.

Adding ".example.com" to cookie_domain didn't work for me. I was using different encryption keys ($config['encryption_key']) for both subdomains too.

When they were made the same, the session was then available across both subdomains.

Stephan
  • 41,764
  • 65
  • 238
  • 329
Vishal
  • 1