Problem with session on default page |
Hi,
I have problem with sessions in CodeIgniter. When user log in to system I have this code: Code: $data_login = array( In general, everything works but when I don't log out and close the page tab, then I will visit the site again [b]$this->session->userdata('logged_in')[/b] returns NULL. When I enter another subpage, everything returns to normal - recognizes the logged in user. Where is a problem?
I'm afraid that's not enough to go on. It can be pretty much anything. But usually it's miss-configured Cookie paths inside Application/Config/Config.
Or you aren't autoloading sessions.
I load session in autoload:
PHP Code: $autoload['drivers'] = array('session'); My sessions config: PHP Code: $config['sess_driver'] = 'files'; @edit: I noticed that this happened on the new hosting. Everything works on old hosting.
Instead of using sys_get_temp_dir try making a sessions folder at the same level as the system folder. Set the permissions as described in the documentation. It may or may not help but is worth the experiment. You can look for the creation of files there as you test for a working session.
Remember that $config['sess_save_path'] must be a full and absolute path.
When I created new folder and edited config.php nothing changed - problem still exists.
In created folder I see session files so I don't know what is wrong.
I just noticed the following which is wrong.
PHP Code: $autoload['drivers'] = array('session'); It should be "libraries" not "drivers" PHP Code: $autoload['libraries'] = array('session'); Sorry for missing that on an earlier read.
I probably found the source of problem.
In my .htaccess: Code: <IfModule mod_rewrite.c> I change: Code: RewriteRule ^(.*)$ https://www.***.pl/$1 [R,L] to: Code: RewriteRule ^(.*)$ https://***.pl/$1 [R,L] and I think it's finally fine. Thank you for help! |
Welcome Guest, Not a member yet? Register Sign In |