Welcome Guest, Not a member yet? Register   Sign In
Sessions getting erased
#1
Sad 

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?!
Reply
#2

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

(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.
Reply
#4

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

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/li...les-driver
Reply
#5

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
Reply
#6

(This post was last modified: 07-24-2015, 05:09 PM by Dracula.)

(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.
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply
#7

Guys, where to place the folder "sessions"? 
Reply
#8

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
Reply
#9

(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.
Reply
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB