Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How r session variables handled in PHP?

Status
Not open for further replies.

bosky

Programmer
Oct 30, 2003
15
IN
Hi There,

I am using PHP as my Scripting language and Apache as the server.

Basically i have been given an assignment but i am unable to come up with an apt solution for it. Can someone just guide me as to from where should i start.

I have a site wheren in the users logs in and when they do so a session variable is created and the user id is stored in it. Now there are certain pages from where the user receives a mail from the site linking to the site.
Now when the user reads this mail and clicks on the link in the mail it opens the respective page on the site.

Now what i want to do is I want to check whether the user is already logged in. If he is logged in it should refresh the site with new details. If he is not logged in it should Open a new window asking him to log in and when he does that it should display the link that has been sent to him as a mail.

Sounds confusing huh? :confused:

Can some one help me?
 
So what you're saying is you want to check all the existing session variables on your machine to see if the user is logged in... yes?

There is no direct access to session variables outside of the current session... but they are stored however you tell them to be stored, on my current system it's default (windows) so they're dumped to a directory, and serialized in a bunch of files.

I think your problem would better be handled by a database... every time a user hits a page update a userid & timestamp row in the DB.

Of course give them a logout button, this will erase all of their entries from the database (or clear their date/time field or something). Otherwise, you're isLogged in check will basically be a SELECT id FROM table WHERE timestamp is less than 10 minutes old... or whatever criteria seems appropriate for your site.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top