Welcome Guest, Not a member yet? Register   Sign In
Session data lost on second page
#1

[eluser]pmhart[/eluser]
Hello,

I am setting up a submission process, after a simple submission the user can add additional data if they'd like to a song tab.

Here is the brief of my code:

controllers/submit.php
Code:
...
function tab() {

$step = $this->uri->segment(3);

...

}else if($step == "save") {

  $obj->null;
  $obj->title = $this->input->post("title");
  $obj->artist = $this->input->post("artist");
  $obj->tab_body = $this->input->post("tab_body");

  $submission_id = $this->submissionModel->create($obj);

  $obj->submission_id = $submission_id;

  $this->securityservice->set_var("last_submission", $obj);

  //LOCATION A
  //debug here
  $submission_obj = $this->securityservice->get_var("last_submission");
  print_r($submission_obj);

  //commented out to use print_r, should ideally redirect
  //redirect("/submit/tab/completed");

}else if($step == "completed") {

  //LOCATION B
  $submission_obj = $this->securityservice->get_var("last_submission");
  print_r($submission_obj);

}

...

}

..

}
...

libraries/securityservice.php
Code:
...
function set_var($name, $value) {
$this->session->set_userdata($name, $value);    
return true;
}
        
function get_var($name) {
return $this->session->userdata($name);
}
        
function clear_var($name) {
$this->session->unset_userdata($name);
}
...


Ok ... so right after I insert into the session and grab the object from the session using the SecurityService library to a different variable, it will print_r the object as expected (see Location A in the code).

When I go to the completed page (by redirect or clicking a link), the object contains no properties, it just says "Object" (see Location B).

This has happened to me other times with the log-in script in which I stored the referring page URI.

Please help!
#2

[eluser]pmhart[/eluser]
Hmm ... my first idea was to try an array instead of an object, and it turns out that it works as an array.

I guess sessions can't understand an object after the next page?

I will have to come back to the login URI being lost issues later.




Theme © iAndrew 2016 - Forum software by © MyBB