Welcome Guest, Not a member yet? Register   Sign In
session userdata being reset/removed
#1

[eluser]bobbob[/eluser]
This might be a CI bug but I am more confident that I did it.

The below code which is the last code run in the footer
Code:
</html>
<?php die(); ?>
leaves this in the session db:
Code:
a:4:{s:9:"user_data";s:0:"";s:5:"event";s:2:"41";s:10:"email_hash";s:27:"58835ca7a23a15eeca0285fb7eb";s:5:"email";s:16:"[email protected]";}

Removing the die() changes it to:

Code:
a:4:{s:9:"user_data";s:0:"";s:5:"event";N;s:10:"email_hash";N;s:5:"email";N;}


What am I missing that happens maybe in the loader class?
Any thoughts would be great. There is no other code of mine in between as you can see.


#2

[eluser]weboap[/eluser]
if you are doing
Code:
<?php die(); ?>
to kill the session can't you use:

Code:
$config['sess_expire_on_close'] = TRUE;  // in config/config.php
#3

[eluser]bobbob[/eluser]
i am not using it to kill the session.
I am using it to clarify that the session is being killed after my code has run but there is still some CI code to run
#4

[eluser]bobbob[/eluser]
Just to help clarify the issue
the end of the action in the controller looks like this when thee session is still good:
Code:
$this->load->view('footer');
  die();
}

Without the die() the session goes bad so no code except CI in between.
Did I find a CI bug?
I am stepping through the CI code that follows but it takes a while Smile
#5

[eluser]Aken[/eluser]
You need to explain what results you're actually looking for, and how you're going about it. We need more information beyond your use of die() and what results you're getting.

By the way, die() the way you're using it does not sound appropriate. Again, post what you're trying to do and we'll recommend something.
#6

[eluser]bobbob[/eluser]
The die() is simply for debugging. At the point where I insert the die() the session is still accurate in the db.
I am trying to find where in the code the session data gets rewritten to the database with the Ns in it instead of my previously set values.
Not sure what else I can show that would help.
This is happening in CI 2.1
As far as I can see It happens between the last load->view call and the actual rendering of the page.
I have been using MacGDP to step through he code after loading the footer but it appears to have a limit on the number of steps. The wine in the fridge is running out...

Thanks again for looking at this
#7

[eluser]Aken[/eluser]
Well we can't tell you what's wrong without knowing what your code looks like.

Why don't you start recreating the page that is having the issue piece by piece, and see when the problem happens again. Then adjust accordingly.
#8

[eluser]bobbob[/eluser]
In case this helps at all.
The controller has this action:
Code:
public function t($hash)
{
  $this->load->model('event_model');
  $this->load->helper('functions');
  
  $data['all'] = $this->event_model->extract_it_all($hash);
  $this->load->view('header');
  $this->load->view('event',$data);
  $this->load->view('footer');
  
}

extract_it_all in the event_model ends with this:
Code:
$userData = array(
   'event' => $ret['event']->id,
   'email_hash' => $email->email_hash,
   'email' => $email->email
  );
     $this->session->set_userdata($userData);
     $this->set_last_update();// does not change session data
     return $ret;
    
    }
The values in the db session table are correct at the end of this model's code.
And the part I really don't get is that the session is also good at the end of the controller code implying that there is only CI code from here to the page rendering that might be causing the issue.

#9

[eluser]gRoberts[/eluser]
If you add `die()` to the View, it will kill the entire script. As a result, this won't allow the result of the CodeIgniter code to run after the View has been parsed.

If you, as others have said above, put `die()` at the bottom of your Action, it should work properly.
#10

[eluser]bobbob[/eluser]
The controller action with die() at the bottom:
Code:
public function t($hash)
{
  $this->load->model('event_model');
  $this->load->helper('functions');
  
  $data['all'] = $this->event_model->extract_it_all($hash);
  $this->load->view('header');
  $this->load->view('event',$data);
  $this->load->view('footer');
  die();
  
}
with the die() it all works fine. It is when the die() is removed that the session userdata is changed by what I think is CI code. I might put this in the CI bug forum.




Theme © iAndrew 2016 - Forum software by © MyBB