Welcome Guest, Not a member yet? Register   Sign In
Sessions, some work, some donn't.
#1

[eluser]smick[/eluser]
Hi,

I've been using Codeigniter for a few years now and today I ran into a session problem. I've had these issues with nearly every site I've developer with codeigniter, and it is sad that it keeps being a problem.

I have a number of sessions that are used across the site, and they work well.

But I'm trying to set a simple session in a model file and I'm getting strange results.

I have the following code:

Code:
if(isset($_POST['category'])) {
                //echo("submitted");
                $category = $this->input->post('category');
                echo("category: $category<br>");
                if($this->session->set_userdata("category", $category)) { echo("session set"); }
                else { echo("session set failed<br>"); }
                echo("category specified, set to: $category " . $this->session->userdata('category') );
            }
            else {
                $category = $this->session->userdata('category');
                echo("no category specified, setting category to: $category " . $this->session->userdata('category'));
            }

It outputs this on first run, when the category post data is sent:

Quote:category: 15
session set failed
category specified, set to: 15 15

When I reload the page without sending the category post data it responds:

Quote:no category specified, setting category to:


This is so strange, because on first run, it fails to set the session variable, but then is able to retrieve the session variable for reporting purposes. Then when I load the page without the post data, it cannot retrieve the session data.

Anyone know what I'm doing wrong?

I have my session config set to the following:

Code:
$config['sess_cookie_name']        = 'RM_sessions';
$config['sess_expiration']        = 60 * 60 * 24 * 30;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;



and my cookie config set thus:

Code:
$config['cookie_prefix']    = "RM_";
$config['cookie_domain']    = "http://recipematcher.com";
$config['cookie_path']        = "/";



Thanks for any help!


Messages In This Thread
Sessions, some work, some donn't. - by El Forum - 03-10-2010, 05:57 PM
Sessions, some work, some donn't. - by El Forum - 03-10-2010, 06:07 PM
Sessions, some work, some donn't. - by El Forum - 03-10-2010, 07:00 PM
Sessions, some work, some donn't. - by El Forum - 03-10-2010, 08:21 PM
Sessions, some work, some donn't. - by El Forum - 03-11-2010, 01:25 AM
Sessions, some work, some donn't. - by El Forum - 03-11-2010, 02:13 AM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 04:00 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 04:27 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 04:29 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 04:31 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 04:33 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 06:01 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 06:07 PM
Sessions, some work, some donn't. - by El Forum - 03-12-2010, 06:55 PM
Sessions, some work, some donn't. - by El Forum - 03-13-2010, 03:42 AM
Sessions, some work, some donn't. - by El Forum - 03-13-2010, 01:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB