CodeIgniter Forums
Losing session in Firefox when redirect to other page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Choosing CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=8)
+--- Thread: Losing session in Firefox when redirect to other page (/showthread.php?tid=62194)



Losing session in Firefox when redirect to other page - nnanh01 - 06-18-2015

Hi all,

I use CI Lib. session to do  the login function. It is always lost when I go to other page

Note that it happens just in Firefox (using FF38.0.5). In Chrome is ok

This is my configuration:

Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = FCPATH.'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

and loaded in every Controller:

Code:
$this->load->library('session');
$this->load->driver('session');

I changed config to database as:
Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

and make the data as:
Code:
CREATE TABLE IF NOT EXISTS `ci_sessions` (
       `id` varchar(40) NOT NULL,
       `ip_address` varchar(45) NOT NULL,
       `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
       `data` blob NOT NULL,
       PRIMARY KEY (id),
       KEY `ci_sessions_timestamp` (`timestamp`)
);

still same problem.

Anyone help!!??

Thanks so much


RE: Losing session in Firefox when redirect to other page - PaulD - 06-22-2015

I had a problem with firefox logins and sessions too a while ago and although I cannot recall the exact solution I am sure one of the things I did was to remove the underscores from the cookie names. I hope that helps :=)


RE: Losing session in Firefox when redirect to other page - Narf - 06-23-2015

(06-22-2015, 05:55 PM)PaulD Wrote: I had a problem with firefox logins and sessions too a while ago and although I cannot recall the exact solution I am sure one of the things I did was to remove the underscores from the cookie names. I hope that helps :=)

That couldn't possibly help, not in the way you think it does. If it does, it's not because of the underscores, but because of a collision and changing the cookie name in any way would "help".


RE: Losing session in Firefox when redirect to other page - mwhitney - 06-26-2015

(06-18-2015, 12:59 AM)nnanh01 Wrote: and loaded in every Controller:


Code:
$this->load->library('session');
$this->load->driver('session');

You should only need
Code:
$this->load->library('session');
The driver will be loaded based on the configuration.


RE: Losing session in Firefox when redirect to other page - nnanh01 - 06-27-2015

(06-26-2015, 01:18 PM)mwhitney Wrote: You should only need
Code:
$this->load->library('session');
The driver will be loaded based on the configuration.

Thanks for all your replies.

Thank mwhitney, I did, but it was not help, too.

Any suggestion??


RE: Losing session in Firefox when redirect to other page - Paradinight - 07-12-2015

How do you call the page eg. Ajax?
Someone on the IRC had the same problem (12 days ago).

Problem was the ajax request. The request was from a other domain. Problem called Same origin policy

https://en.wikipedia.org/wiki/Same-origin_policy

Solution
http://caniuse.com/#feat=cors
http://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain/9523871#9523871

header("Access-Control-Allow-Origin: http://foo.example"); in the Controller. http://foo.example is the ajax site. Smile