Welcome Guest, Not a member yet? Register   Sign In
Appending to session array
#1

[eluser]Unknown[/eluser]
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

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

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

Thanks for any help
#2

[eluser]Krzemo[/eluser]
Code:
$history = $this->session->userdata('history');
$history[] = array(time() => curPageURL());
$this->session->set_userdata('history', $history);
I hope you are using database sessions for that. I also have no idea for how long you are going to keep that history, but I'd keep it in a sessions data only if there are going to be no more then just few items in the array...




Theme © iAndrew 2016 - Forum software by © MyBB