Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] lost session for some pages
#1

[eluser]peter222[/eluser]
I know that in many posts people can't find why sometimes they session data are lost. This day I found solution, maybe it help to anyone. In my case problem was that some views was cached by Cache_fragment library. Some of them was cached with http:// links, some with http://www. What was it possible? Because I used this code to set base_url in config:

Code:
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

So, base_url() was sometimes http://mysite.com, sometimes http://www.mysite.com

Session registered in http://mysite.com was lost in http://www.mysite.com.

Solution is to set always static base_url() in config:

Code:
$config['base_url'] = 'http://www.mysite.com';

or force to add www in .htaccess




Theme © iAndrew 2016 - Forum software by © MyBB