Page 1 of 1

Can you set cookies anywhere?

Posted: Sat Nov 15, 2003 2:24 pm
by Davo
Okay, I have a little project on the way but somethings bothering me at the moment.

Ive created a page to confirm the details of your login attempt. If your login matches with the database, it goes to one page. If it doesnt, it goes to another. You can see for yourself at http://www.blinkingeye.net

Both of the messages are in a "Show if.. " statement. So my question is, can I have it so if your login attempt was successful, it sets the cookies. Ive tried moving the cookie script inside the "Show if.." statement but it doesnt work. Any help would be grateful, cheers.

Posted: Sat Nov 15, 2003 4:59 pm
by qads
do you get any errors messages? it prolly cos of the headers, read this and it will...uh..show you the light. :P

viewtopic.php?t=1157

Posted: Sat Nov 15, 2003 5:16 pm
by Davo
Nah, I dont get any error messages at all. It just doesnt record the cookies when I place it within the "Show if recordset is not empty" field.. but I'd really prefer it if is was in that field. Either that or theres another way of doing it which im completely forgetting about.

Posted: Sat Nov 15, 2003 8:33 pm
by Davo
Okay, heres a simpler answer..

At the moment, the way the logging in takes place is this:
The user goes to "user_login.php" to enter the username and password. Then it directs to "login_confirmation.php" which is really self-explanatory. If the username and password match up in the database it displays "Welcome back, username" if it doesnt then it shows "The information you displayed was incorrect, try again blah blah". At the moment its storing the cookies whether the password and usernames wrong or not.

So my question is, is there a way for the user to go to "user_login.php" then to "login_confirmation.php" to see whether its correct, and if it IS correct it goes to "user_home.php" where it stores the cookie. Does that make sense?

Im asking because Im only able to store the cookie on the page after the login page. Im not sure how to carry on the username and password, to say maybe 2 pages after you have logged in.

If that didnt make sense, flame me.