PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 24th, 2000, 07:12 AM
emanuel emanuel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 1 emanuel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hello

I'm working on a Usersystem, and currently it works kind-of like this:

the user logs on on the net,
form method=post action=$php_self)
when the username/password was sent, it calls the function to check username/password, if they match with those in the database, a cookie is set containing the password md5 encrypted and some additional information (like group the user is in).
I've made everything with one if-loop...
before it enters the if-loop, the verification function is called, afterwards it enters the if loop, checks to which group the user belongs (reads it from the cookie). If the cookie isn't set, it prompts the user the login form.

My problem is that it seems like the cookie isn't set fast enough because it prompts the user to login again. If loging in again, everything works fine. the cookie gets set the first time you login.

I'm asking myself now what may cause this, if anyone already had a similar problem and if yes, how he got around with it.
I don't like the idea of splitting the login-, verification- and 'main'-part(s) of the script into 3 different files. But if there's no workaround for that... If you want to see the source code, drop me an e-mail and I'll send it to you.

greetings

emanuel nacht

Reply With Quote
  #2  
Old March 24th, 2000, 07:36 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
Cookies aren't available in the process in which they are set. Consequently, your cookie won't be available until the 3rd time thru the process:

1) No cookie - display login
2) Process login - set cookie
3) cookie available from here forward

What you should do is set a flag when the cookie is set so that the script "knows" that it already has the cookie value (because it just set the value) and doesn't need to read the cookie.

Reply With Quote
  #3  
Old March 24th, 2000, 07:37 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I got this from PHP's website...

>>Cookies will not become visible until the next loading of a page that the cookie should be visible for.

Unfortunately, the only workaround I've found is exactly the one you don't want to do, which is splitting up the login process into three different pages
1. Login page
2. Process login information and set cookie in second script page
3. Test cookie existence in third script page and redirect user to either accessible page or back to login form/possibly a page telling them that cookies need to be used.

I, too, would like to know of any other workarounds other than the above.

Reply With Quote
  #4  
Old March 24th, 2000, 10:51 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
I don't see why this is such a problem.

Why does the process that sets the cookie have to read it???

Do you have scripts that read a record from a db table that was just written by the same script?


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > $php_self and cookies

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap