[eluser]carvingCode[/eluser]
Wizard (or others looking on),
Having an interesting problem with the conversion to sessions. All works fine if I open only one search results window. (This window has a chart and graph and a button to download the result's dataset.) The correct dataset is downloaded. The download is generated by an identical search based upon the session data I saved during the initial search.
But, if I leave that window open and perform another search (which opens a second window), the first search results window can't create and download it's dataset. The second search downloads fine.
It appears that the session data may be getting deleted, or I'm just not thinking about this correctly..
I'm writing a unique ID into the session date for each search.
Code:
/* Prep for writing to cookie - for file download. */
$id = now() . $this->session->userdata('session_id');
$cookie = array(
'name' => $id,
'url_title' => $url_title,
'title' => $title,
'years' => base64_encode(serialize($years)),
'locations' => base64_encode(serialize($locations)),
'option' => base64_encode(serialize($option)),
);
$this->session->set_userdata($cookie);
I am checking for this ID to then load from the session data the original $_POST vars to perform another search.
Code:
/* Last segment contains id of cookie (stored search params) */
$segment = $this->uri->segment($this->uri->total_segments());
if ($this->session->userdata('name') != $segment) {
$continue = FALSE;
} else {
/* Arrays serialized to store in cookie. */
/* So unserialize to store back to array. */
$url_title = $this->session->userdata('url_title');
$title = $this->session->userdata('title');
$years = unserialize(base64_decode($this->session->userdata('years')));
$locations = unserialize(base64_decode($this->session->userdata('locations')));
$option = unserialize(base64_decode($this->session->userdata('option')));
}
I'm sure the problem is either the way I'm creating the unique ID, or in the way I'm reading the values back from the session data.
Would appreciate feedback.
TIA
Randy