Can you set cookies anywhere?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Davo
Forum Newbie
Posts: 3
Joined: Sat Nov 15, 2003 2:24 pm

Can you set cookies anywhere?

Post 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.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
Davo
Forum Newbie
Posts: 3
Joined: Sat Nov 15, 2003 2:24 pm

Post 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.
Davo
Forum Newbie
Posts: 3
Joined: Sat Nov 15, 2003 2:24 pm

Post 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.
Post Reply