Jump to content

Codeigniter session array


c_pattle

Recommended Posts

In my core controller I'm trying to create an array of the user's history.  I am creating an array and then setting the key as the time and the value as the page URL.  However the problem that I'm having is that the previous array seems to get overwritten so there is only ever one key and value pair in the array. 

 

How can I do it so that instead each page will get appended to the array

 

$history = array(
    time() => curPageURL()
);

$this->session->set_userdata('history', $history);

 

Thanks for any help

Link to comment
https://forums.phpfreaks.com/topic/259298-codeigniter-session-array/
Share on other sites

How far back do you want to go?  I have current and previous set up like this:

 

// Set the current URL the user was browsing
$this->session->set_userdata('previous', $this->session->userdata('current'));

// Set the current URL the user is browsing
$this->session->set_userdata('current', uri_string());

 

Not sure what exactly you're interested in doing, but I've written a tracker in CI that marks the controller + method + slug by user_id and is quite effective for marking things as "new" or not.  If interested I can post links to my github.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.