![]() |
Session data & sub-domains - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Session data & sub-domains (/showthread.php?tid=9098) |
Session data & sub-domains - El Forum - 06-11-2008 [eluser]antiver[/eluser] I have my domain setup so that any request sent to anything.mydomain.com is handled by a dedicated server, and apache virtual host settings pass all requests to the same CI install. My goal, is to have addresses like http://antiver.mydomain.com/ be handled by http://mydomain.com/controller/function/antiver Furthermore, I have my default controller ($route['default_controller']) happily detecting if http://username.mydomain.com/ actually contains a username, and calling the right controller/function to handle the request. So here's the problem... when you login on http://mydomain.com , and then load http://username.mydomain.com , you're suddenly not logged in anymore. Session data isn't carrying over. I read this thread- http://ellislab.com/forums/viewthread/70819/ and tried both: Code: $config['cookie_domain'] = ""; Code: $config['cookie_domain'] = ".mydomain.com"; But in either case, the session data is being kept separately. Of course, I need this to work for an unlimited number of sub-domains (for any username.mydomain.com). Any suggestions appreciated! Session data & sub-domains - El Forum - 06-12-2008 [eluser]esra[/eluser] Along with the cookie domain change, try using DB_Session to record your session data to your database. Change the session filename config value in the config files for your domain and subdomains to something like all_sessions. I experimented with this earlier and it seemed to work fine. I'm doing something similar for authorization. All of my Khaos ACL tables were renamed to have a fixed all_ prefix. The above should work if the data for your domain and subdomains are stored in a single database. If this is not possible (need to use multiple databases) or if some of your subdomains are located on remote servers, I may have another solution but it involves using xml-rpc. |