CodeIgniter Forums
Sessions getting erased - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Sessions getting erased (/thread-62520.html)



Sessions getting erased - orsan - 07-23-2015

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?!


RE: Sessions getting erased - Avenirer - 07-24-2015

Are you using database to hold the session data? Or file system? We need more details...


RE: Sessions getting erased - Abhishek Singh - 07-24-2015

(07-24-2015, 01:18 AM)Avenirer Wrote: Are you using database to hold the session data? Or file system? We need more details...

I'm facing the same problem, I'm using file system to store the sessions.


RE: Sessions getting erased - Avenirer - 07-24-2015

(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...

I'm facing the same problem, I'm using file system to store the sessions.

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/libraries/sessions.html#files-driver


RE: Sessions getting erased - jdriddle - 07-24-2015

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


RE: Sessions getting erased - Dracula - 07-24-2015

(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.

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

It's about sessions not cookies and is not a problem at server level.


RE: Sessions getting erased - orsan - 07-26-2015

Guys, where to place the folder "sessions"? 


RE: Sessions getting erased - jdriddle - 07-27-2015

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


RE: Sessions getting erased - Abhishek Singh - 07-30-2015

(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.

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

This helped thank you Smile I changed the cookie_domain to my domain name and it works now. Thank you again. Great help.


RE: Sessions getting erased - raknjak - 03-29-2017

So it was about cookies indeed.
On localhost I just leave cookie_domain empty and it seems to work.