Dynamic Base URL Destroys Session |
[eluser]Mr Lazy[/eluser]
Hello, I am dynamically changing the base url from a DNS name to an IP address (if the client's IP address is within a certain range), but in doing this, the session data is destroyed. In config.php I have: Code: $config['sess_cookie_name'] = 'ci_session'; http://example.com/login to http://123.123.123.1/login Can anyone help me and shed any light on this? Many Thanks, L
[eluser]Wuushu[/eluser]
Your session identifier cookie (the one and same) is not available on both domains, your DNS name domain, and your IP-address "domain". So when the user travels from one to the other, the user gets treated as a new visitors discarding old session data. Just a guess.
[eluser]Mr Lazy[/eluser]
Right OK, that makes sense. So if I want to keep the session alive across domains, any suggestions how that may be possible? Or another solution (that has just popped into my head), is to redirect the user to the new IP address before setting the session... mmmm... Thanks L
[eluser]xeroblast[/eluser]
i dunno if i get this right.. try setting a cookie in the example.com like this set_cookie(array('name' => 'the name', 'value' => 'the value', 'domain' => '.123.123.123.1')); then in your 123.123.123.1 domain get the cookie like this get_cookie('the name'); i dunno if i implement it correctly...
[eluser]Mr Lazy[/eluser]
OK, thanks for the help and suggestions but I solved the issue upstream before the request gets to CI. Probably a better solution in the end... |
Welcome Guest, Not a member yet? Register Sign In |