Welcome Guest, Not a member yet? Register   Sign In
Where is the best place to read a cookie and set session variables???
#1

[eluser]bevans[/eluser]
I am doing a "Remember Me" option to let people stay logged in... I have a small problem and need some direction, please.

Currently, we are setting some variables in the session when a person logs in so their login information will persist across all pages.
But with the current settings, once the browser is closed the session is destroyed and the person must log in again when they come back to the site.

With the Remember Me option I set a cookie which is checked when they return to the site, then sets the session variables to show the person as logged in so they can persist across all pages. When the person hits the site they get a welcome back message, but the rest of the page is not showing their individual options, and must be refreshed. Once the page is refreshed they get all individual options and their information will persist across all pages.
I am guessing that the session information I am setting is getting set too late. Am I correct?

My question is where can I set the remember me cookie, read it, then set the session information so that the instant the person hits the site they are logged in with all user options and do not have to refresh the page?
I tried in the Loader.php library, but that is too soon and will not allow me to query the db for the users status to see if they are active or not. I tried a hook, but that has not worked either.

Let me know if I need to clarify what I am asking.

Thanks,
B
#2

[eluser]Nikhil Vijayan[/eluser]
can u give me a rough idea about how you coded it ?

some parts of code ?

so i can give a try ...
#3

[eluser]Daniel Eriksson[/eluser]
I have my own session handling library that is mostly just a thin wrapper on top of native PHP sessions (set, get, clear/unset, destroy, ...). In addition to the wrapper functions it also has a contructor that does session_start() and sets everything up, including "remember me" functionality, if it's a new session.

The library is loaded early through autoload.php, so by the time the controller is called the session is already fully set up and populated with suitable data (like userid, credentials, ...).




Theme © iAndrew 2016 - Forum software by © MyBB