Welcome Guest, Not a member yet? Register   Sign In
how to put dynamic info in an array?
#1

[eluser]dadamssg[/eluser]
Im trying to put dynamic info in an array. Im setting a session variable to hold which page the user is on so if they login they will be redirected to the page they were on...this isn't working
Code:
$eventid = $row->eventid;
        $newdata = array(
                   'page'  => "event/index/$eventid",
               );
        $this->session->set_userdata($newdata);
#2

[eluser]WebsiteDuck[/eluser]
Take out the comma at the end of this line
Code:
'page'  => "event/index/$eventid",
#3

[eluser]dadamssg[/eluser]
just tried it...still not working
#4

[eluser]WebsiteDuck[/eluser]
Make sure $eventid contains data... make sure session library is loaded

What happens when you try to retrieve the page from session?
#5

[eluser]saidai jagan[/eluser]
Code:
echo $eventid = $row->eventid;
what it returns ?
#6

[eluser]dadamssg[/eluser]
hmmm its returning the right content. It will hold "event/index/867". But i can't seem to to get it to work in a redirect.

heres the redirect its being used in...in another controller
Code:
$page = $this->session->userdata('page');
                    redirect("$page");
#7

[eluser]JHackamack[/eluser]
try passing in a second param like:
redirect($page, 'refresh');

or
redirect($page, 'location');
#8

[eluser]dadamssg[/eluser]
nope, still nothing. im thinkin about using the normal PHP header() function
#9

[eluser]dadamssg[/eluser]
welp, the header() won't work either...wtf.

this is working, where mains is a controller and performance is a function
Code:
$newdata = array(
                   'page'  => 'mains/performance',
               );
        $this->session->set_userdata($newdata);
however this isn't, event is a controller and $eventid is holding a number because im echoing it out onto the page
Code:
$page = "event/index/".$eventid;
        $newdata = array(
                   'page'  => $page,
               );
        $this->session->set_userdata($newdata);
#10

[eluser]JHackamack[/eluser]
One other thing to check: Are you loading the URL helper?




Theme © iAndrew 2016 - Forum software by © MyBB