Welcome Guest, Not a member yet? Register   Sign In
Session Data Lost After One Page Refresh
#1

[eluser]pmhart[/eluser]
I am using session data to store a "from page" while the user logs in ...

Code:
function setFromPage($url) {
  $this->session->set_userdata("from_page", $url);
}
        
function getFromPage() {
  return $this->session->userdata("from_page");    
}
        
function clearFromPage() {
  $this->session->unset_userdata("from_page");
}

From a restricted page (ie submission page) I do the following:

setFromPage($this->uri->uri_string);
redirect("/login");

When I'm on the login page, at the top I have:

echo $this->libraryName->getFromPage();

It will echo the first time the page loads, but when I hit refresh the value goes away ...

I need it to stay until they login! Do I have to re-set it each time the page loads?
#2

[eluser]pmhart[/eluser]
no one?

Sad
#3

[eluser]Ruben Müller[/eluser]
What is your session config in "application/config/config.php"? Especially "sess_expiration"?
#4

[eluser]pmhart[/eluser]
$config['sess_expiration'] = 7200;

I am using database based sessions. A lot of the data actually remains in the session such as the user info ...

It's just this one value that seems to get cleared ...
#5

[eluser]stef25[/eluser]
Quote:It’s just this one value that seems to get cleared ...

id say there is some code elsewhere in your app that clears it. search all the files in your app for "from_page", that would be a start.

db sessions, you mean this one? in that case you should be using $this->db_session->set_userdata . it works great for me. you could check your sessions table to see whats going on
#6

[eluser]Turv[/eluser]
If you monitor your sessions table in your database when you do a page refresh, do you get assigned a new session on ever page, or do you just have one session stored.
#7

[eluser]pmhart[/eluser]
I renamed the var to "fromPage", taking out the underline, and still the same problem.

I used a 3rd party search (b/c windows sucks) to search for the clear method and didn't find it.

I will review the session table and try db_session ...
#8

[eluser]stef25[/eluser]
fyi for searching in files in Win you can use Notepad++ which can search in files of any folder you indicate, or Aptana which can search in files for any Project you create there. once you start working with large apps you'll want to use this Smile

good luck with db_session; i find it very useful since you get past the 4KB limitation of data that can be stored in cookies and its easy to set up.




Theme © iAndrew 2016 - Forum software by © MyBB