CodeIgniter Forums

Full Version: sessions and subdomains
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]aeternuslibertas[/eluser]
Hi all I have a quick question, I currently set up a very simple login/members area using the session class.
I'm also using a sub domain as a flag to switch between languages. For example, mywebsite.com automatically loads everything in the english language, however if I point my browser spanish.mywebsite.com it triggers everything to fetch the respective spanish language files ( also within code igniter.. so there is only one controller/view page per page, all the language switching is done with the codeigniter language folder). My problem is that when I log in either through the mywebsite.com or spanish.mywebsite.com/ the session does not allow me to switch between languages without requesting me to login again.
Is the cookie that is created by the session class use URL data to validate it self or do you guys think it is a bug in my code or perhaps code igniters code? Smile thank you in advance

El Forum

[eluser]CroNiX[/eluser]
Quote:Is the cookie that is created by the session class use URL data to validate it self
Not that I know of. I would guess it has to do with the $config['cookie_domain'] setting, although I haven't checked to see if the session cookies use these values (I assume they would). To use domain-wide, you'd need to make the cookie domain like ".yoursite.com" with a . in front. Then it should work on yoursite.com, www.yoursite.com, es.yoursite.com or whatever.

You can use firebug/firecookie or webkits debugger to see the names, values, domain, expiration, etc, of the cookies to see if they are being set correctly.

El Forum

[eluser]aeternuslibertas[/eluser]
[quote author="CroNiX" date="1342147549"]
Quote:Is the cookie that is created by the session class use URL data to validate it self
Not that I know of. I would guess it has to do with the $config['cookie_domain'] setting, although I haven't checked to see if the session cookies use these values (I assume they would). To use domain-wide, you'd need to make the cookie domain like ".yoursite.com" with a . in front. Then it should work on yoursite.com, www.yoursite.com, es.yoursite.com or whatever.

You can use firebug/firecookie or webkits debugger to see the names, values, domain, expiration, etc, of the cookies to see if they are being set correctly.[/quote]

WOW I TOTALLY OVERLOOKED THAT SETTING. THANK YOU VERY MUCH. Problem Fixed!