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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.