CodeIgniter Forums
Session Fix - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Session Fix (/thread-57034.html)



Session Fix - El Forum - 02-08-2013

[eluser]EyeAmN8[/eluser]
Since there is a lot of open ended posts about CI sessions not working I figured I would share this. I was having problems using sessions and it was giving me a hard time. All it ended up being was the config.php was not setup properly.

My base url and cookie domain did not match! My base url was http://website.com and my cookie domain was www.website.com FYI - website.com is not my site, just an example

Incase you are new to CI like me check your config file to make sure that the two fields match


CodeIgniter v 2.1.3, with pretty much all of the default configs

application
-config
-config.php
line 17
Code:
$config['base_url'] = 'http://website.com';
line 268 - 271
Code:
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "website.com"; // problem was www.website.com
$config['cookie_path']  = "/";
$config['cookie_secure'] = FALSE;

This doesn't cover all the details, but just the "basic" configuration that I missed!