EllisLab/CodeIgniter — Issue #700: Can't fetch flashdata if database sessions are being used
Author: AeroCross
Created: 2011-11-23 17:03:06+00:00
State: open

In any given controller, setting database sessions to TRUE:

```php
load->library('session');

$this->session->sess_destroy(); // all the session data up to here should be destroyed, but the remaining data should persist
$this->session->set_userdata('message', 'This is the userdata message.');
$this->session->set_flashdata('message', 'This is the flashdata message.');

var_dump($this->session->flashdata('message')); // bool(false)
var_dump($this->session->userdata('message')); // string(29) "This is the userdata message."
?>
```

... but if I set database sessions to FALSE:

```php
load->library('session');

$this->session->sess_destroy(); // all the session data up to here should be destroyed, but the remaining data should persist
$this->session->set_userdata('message', 'This is the userdata message.');
$this->session->set_flashdata('message', 'This is the flashdata message.');

var_dump($this->session->flashdata('message')); // string(30) "This is the flashdata message."
var_dump($this->session->userdata('message')); // string(29) "This is the userdata message."
?>
```

My database scheme is the exact same scheme as the one in the [user guide][db-scheme].

I don't know what kind of configuration can corrupt the generation of the flashdata - the only think I could think about is the cookie limit of 4K, since I'm encrypting the session and such (but since there are database sessions, I thought that wasn't the problem). The size of the serialized array shouldn't be a problem either (since the example is really small and there is no other data around).

It's worth noting that the problem appears ONLY if I destroy the session __before__ calling the set_userdata.

I don't know what other information to give out. Is this the proper behavior or it's a bug?

[db-scheme]: http://codeigniter.com/user_guide/libraries/sessions.html#saving-session-data-to-a-database "Codeigniter User Guide: Saving session data to a database"