c_pattle Posted March 19, 2012 Share Posted March 19, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259298-codeigniter-session-array/ Share on other sites More sharing options...
trq Posted March 19, 2012 Share Posted March 19, 2012 I'm not a code ignitor user, but something like: $this->session->set_userdata('history', array_merge($this->session->get_userdata('history', $history)); should do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/259298-codeigniter-session-array/#findComment-1329238 Share on other sites More sharing options...
Mahngiel Posted March 20, 2012 Share Posted March 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259298-codeigniter-session-array/#findComment-1329257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.