Welcome Guest, Not a member yet? Register   Sign In
Getting New Session Every Page Load
#1

[eluser]Michael Wales[/eluser]
This issue just cropped up recently - to be honest, I'm not sure what I changed within my code to make it occur. This application is currently being developed used on localhost - I am receiving a new session upon every page load.

This error is occurring in both Firefox and IE, so it's not just IE's retarded cookie management. I am currently loading the session class via autoload. I do backup my entire application and the database and transfer it to a USB drive to work on while away from home. The web server is xampp running on the USB drive, but I believe the same was occurring at home on a full xampp installation.

config.php
Code:
$config['sess_cookie_name'] = 'obfuscated';
$config['sess_expiration'] = 72000; // 1 Year
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "localhost";
$config['cookie_path'] = "/";

log-2007-08-03.php (Full log to Level 4 - went to index.php, clicked my home link which links to the same location - notice the session load and not finding the variable)
Code:
DEBUG - 2007-08-03 06:52:24 --> Config Class Initialized
DEBUG - 2007-08-03 06:52:24 --> Hooks Class Initialized
DEBUG - 2007-08-03 06:52:24 --> No URI present. Default controller set.
DEBUG - 2007-08-03 06:52:25 --> Router Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Output Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Input Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Global POST and COOKIE data sanitized
DEBUG - 2007-08-03 06:52:25 --> URI Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Language Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Loader Class Initialized
DEBUG - 2007-08-03 06:52:25 --> Helpers loaded: url, form
DEBUG - 2007-08-03 06:52:25 --> Database Driver Class Initialized
DEBUG - 2007-08-03 06:52:26 --> Session Class Initialized
DEBUG - 2007-08-03 06:52:26 --> Encrypt Class Initialized
DEBUG - 2007-08-03 06:52:26 --> A session cookie was not found.
DEBUG - 2007-08-03 06:52:26 --> Controller Class Initialized
DEBUG - 2007-08-03 06:52:26 --> Model Class Initialized
DEBUG - 2007-08-03 06:52:26 --> Model Class Initialized
DEBUG - 2007-08-03 06:52:26 --> File loaded: F:/xampp/htdocs/system/application/views/_global/header.php
DEBUG - 2007-08-03 06:52:26 --> File loaded: F:/xampp/htdocs/system/application/views/_global/footer.php
DEBUG - 2007-08-03 06:52:26 --> File loaded: F:/xampp/htdocs/system/application/views/index.php
DEBUG - 2007-08-03 06:52:26 --> Final output sent to browser
DEBUG - 2007-08-03 06:52:27 --> Total execution time: 2.4144
DEBUG - 2007-08-03 06:52:28 --> Config Class Initialized
DEBUG - 2007-08-03 06:52:28 --> Hooks Class Initialized
DEBUG - 2007-08-03 06:52:28 --> No URI present. Default controller set.
DEBUG - 2007-08-03 06:52:28 --> Router Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Output Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Input Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Global POST and COOKIE data sanitized
DEBUG - 2007-08-03 06:52:29 --> URI Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Language Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Loader Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Helpers loaded: url, form
DEBUG - 2007-08-03 06:52:29 --> Database Driver Class Initialized
DEBUG - 2007-08-03 06:52:29 --> Session Class Initialized
DEBUG - 2007-08-03 06:52:30 --> Encrypt Class Initialized
DEBUG - 2007-08-03 06:52:30 --> A session cookie was not found.
DEBUG - 2007-08-03 06:52:30 --> Controller Class Initialized
DEBUG - 2007-08-03 06:52:30 --> Model Class Initialized
DEBUG - 2007-08-03 06:52:30 --> Model Class Initialized
DEBUG - 2007-08-03 06:52:30 --> File loaded: F:/xampp/htdocs/system/application/views/_global/header.php
DEBUG - 2007-08-03 06:52:30 --> File loaded: F:/xampp/htdocs/system/application/views/_global/footer.php
DEBUG - 2007-08-03 06:52:30 --> File loaded: F:/xampp/htdocs/system/application/views/index.php
DEBUG - 2007-08-03 06:52:30 --> Final output sent to browser
DEBUG - 2007-08-03 06:52:30 --> Total execution time: 2.2064

Does anyone have any helpful ideas?
#2

[eluser]Michael Wales[/eluser]
Figured it out, I needed to set the cookie's domain to a blank string...

I'm confident I have used localhost in the past when developing on localhost - can anyone explain what is the proper setting (when on localhost) and why it would not work now?
#3

[eluser]Peter Ivanov[/eluser]
i have the same problem too even that i have cookie’s domain as a blank string

so i switched to native PHP sessions instead of CI sessions
#4

[eluser]Scott - Beyond Coding[/eluser]
For local development (I use XAMPP too), I've found it's best to set up a full-style domain instead of just using "localhost".. ie. set the cookie domain to something like .local.yoursite.com and chances are all your session problems will magically disappear Smile

See this thread: http://ellislab.com/forums/viewthread/45450/
#5

[eluser]Sean Downey[/eluser]
Alas this has still not fixed the problem for me :-(
#6

[eluser]adamp1[/eluser]
Seems strange I had this problem once and by removing the domain and replacing it with a blank it then worked. This seems to be a very common problem which so far has no universal solution.




Theme © iAndrew 2016 - Forum software by © MyBB