Current location: Hot Scripts Forums » Programming Languages » PHP » Need general guidelines to Login/Register/Logout with sessions...


Need general guidelines to Login/Register/Logout with sessions...

Reply
  #1 (permalink)  
Old 10-05-06, 10:47 PM
dreasi0n dreasi0n is offline
New Member
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need general guidelines to Login/Register/Logout with sessions...

Hi there,

I'm building a site that is supposed to evolve to a new stage allowing the users to Register, Login and Logout. I'm already using session to count site visits.

I know the basic on working with sessions and cookies but I have some problems when trying to understand some aspects of it all together. So if anyone could tell me the general idea or point me to a tutorial I would appreciate.

My questions or difficulties are:
  • When a user navigates to the site, how can I know if it is a guest? I ask this because the feature "Remember me" on the login page. How can I remember the user? Is this with cookies?
  • If this is with cookies, what should I save in the cookie? The session ID? The username and password MD5'ed? Can I assume that the cookie info is correct? How can I load the user old session?
  • How can I keep counting visits with the new session implementation? Can I create a session before a valid login? Is this secure? Can I transfer a guest session to a valid user session when the guest user log in?
  • When the user log out do I destroy the session or do I set a session variable to False to indicate that the user is not logged in? And how can I prevent a "remember me" to automatically login after the user selects to log out?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-05-06, 11:13 PM
mousegu mousegu is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dreasi0n
Hi there,

I'm building a site that is supposed to evolve to a new stage allowing the users to Register, Login and Logout. I'm already using session to count site visits.

I know the basic on working with sessions and cookies but I have some problems when trying to understand some aspects of it all together. So if anyone could tell me the general idea or point me to a tutorial I would appreciate.

My questions or difficulties are:
  • When a user navigates to the site, how can I know if it is a guest? I ask this because the feature "Remember me" on the login page. How can I remember the user? Is this with cookies?
  • If this is with cookies, what should I save in the cookie? The session ID? The username and password MD5'ed? Can I assume that the cookie info is correct? How can I load the user old session?
  • How can I keep counting visits with the new session implementation? Can I create a session before a valid login? Is this secure? Can I transfer a guest session to a valid user session when the guest user log in?
  • When the user log out do I destroy the session or do I set a session variable to False to indicate that the user is not logged in? And how can I prevent a "remember me" to automatically login after the user selects to log out?

Thanks
1. Yes, the "Remember Me" function that many sties use simply put a cookie on the user computer, then search for it every times the page loads. If its there, then you know its a user and can log them in automatically. If its not, then either its a guest or the user lost/deleted his cookie.

2. I keep the username and password (MD5-ed, preferably). You only create the cookie after the user has sucesssfuly logged in, so the info muct be correct.

3. Umm, lost me here, sorry.

4. When they click logout you can also delete the cookie if you want, or direct them to a page that won't run the auto-login script.
__________________
SSP
Professional Web Design

SSP Website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-06-06, 12:01 AM
dreasi0n dreasi0n is offline
New Member
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
The 3rd point explained...

First of all, thank you for your help...

About the 3rd point what I mean is:

Right now I start a session for everyone that enters my site (by now everyone is guest since there is no registration) and on top of every page, I check if $_SESSION['visitcount'] equals 1. If not, I increment my counter and set it to one.

My question is... Will I create a session as soon as someone arrives to the site and do the incrementation? What if that guest logs in? Will I set up the variables on the current session or create a new one?

One more thing... If a known user logs in can I load a previows session (with variables)?

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with sessions in login form zoliky PHP 6 07-17-06 04:08 AM
No listing guidelines Gunner General HotScripts Site Discussion 3 03-21-06 04:07 AM
sessions not working, please help! tallpaul858 PHP 2 04-29-05 07:23 AM
Weird behaviour with sessions Skeleton Man PHP 1 10-27-04 10:42 PM
Multiple sessions Kaanha PHP 2 01-16-04 11:39 AM


All times are GMT -5. The time now is 10:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.