Sessions getting erased |
Dear guys,
I've been using CodeIgniter, but I'm stuck at a very weird problem. While using version 3.0 with Session Library autoloaded, I noticed that my $_SESSION is not holding values from one page to another. I checked with "var_dump" that the variables are saved correctly. However, when I retrieve the session from another page, everything was gone... What is happening?!
Are you using database to hold the session data? Or file system? We need more details...
Website: http://avenir.ro
07-24-2015, 12:53 PM
(This post was last modified: 07-24-2015, 12:54 PM by Avenirer. Edit Reason: added link to the user guide ) (07-24-2015, 05:37 AM)Abhishek Singh Wrote:(07-24-2015, 01:18 AM)Avenirer Wrote: Are you using database to hold the session data? Or file system? We need more details... If you're using file system to store the session, make sure you've set up the path to the sessions folder correctly and (if you're on linux) make that folder writable. http://www.codeigniter.com/user_guide/li...les-driver Website: http://avenir.ro
Assuming that your web user has permissions to the /sessions folder, then this is most likely to be a setup issue at the web server level.
Internet Explorer does not like to serve cookies to anything less than a fully qualified domain name i.e. sub.domain.tld. You can work around this quirk by modifying the config file for your environment (development, production, etc): $config['cookie_prefix'] = ''; $config['cookie_domain'] = 'sub.domain.tld'; $config['cookie_path'] = '/'; $config['cookie_secure'] = FALSE; $config['cookie_httponly'] = FALSE; When serving from localhost, it would be best to set a fully qualified domain in your hosts file and an appropriate virtual host in your web server config. That way you never have to worry about the url pointing to http://localhost/. Hope that helps. Dennis (07-24-2015, 01:37 PM)jdriddle Wrote: Assuming that your web user has permissions to the /sessions folder, then this is most likely to be a setup issue at the web server level. It's about sessions not cookies and is not a problem at server level.
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Let me be more clear:
In order to access the data saved in the session, you must have the session cookie. If the session cookie is not loaded when the page reloads, doing a var_dump of $_SESSION will be empty. So there are two possible issues: 1. The web user doesn't have permission to write to the sessions folder. 2. The browser isn't sending the cookie back to the server. One of these will be the issue. Dennis
(07-24-2015, 01:37 PM)jdriddle Wrote: Assuming that your web user has permissions to the /sessions folder, then this is most likely to be a setup issue at the web server level. This helped thank you I changed the cookie_domain to my domain name and it works now. Thank you again. Great help.
So it was about cookies indeed.
On localhost I just leave cookie_domain empty and it seems to work. |
Welcome Guest, Not a member yet? Register Sign In |