Welcome Guest, Not a member yet? Register   Sign In
Sessions working differently with and without WWW in url
#1

I've used the Codeigniter sessions library for user authentication.

Everything was working fine,
but i now noticed that sessions created by a page on http://mysite.com are not being recognized by pages on http://www.mysite.com

Seems like this problems has been present from the beginning. I could just notice it now.

Can someone who had the same problem and had solved it, please help me?
Reply
#2

Well... www is actually a subdomain, and your session probably has valability only for the domain. So, in the config.php you should change the name of the cookie_domain parameter from something like:

PHP Code:
$config['cookie_domain']    = 'yourdomain.com'

to:

PHP Code:
$config['cookie_domain']    = '.yourdomain.com'

(notice the dot...)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB