cookies...[RESOLVED thanks]
hello,
I need to make a login page.
back when I used to program in ASP I was reading the username and pasword comparing it to thr one in the databse and if it was correct then I sould setup a cookie with a TRUE value and then in each page I would have check if the cookie exist and if so I would have know that the user is still loged.
when the user closes the browzer the cookie vanished. and the session is over.
so why am I telling you all this?
because in PHP I cannot do that... it tells me to put the SetCookie() function on top of the page so I cannot check the database before puting the cookie...
what can I do?
I hope the question is clear...
thanks
ok but please answer this:
can I make output in an "if" statement before setting the cookie?
for example: (pseudo code)
if (username != username in databease or password != assword in database)
{
echo "wrong password"
}
else
{
setcookie();
}
is this fine?
so the corect way of doing this is ...
Quote:
Originally posted by CornedBee
How do you know that the cookie vanishes? I could probably set the cookie manually by editing the cookie file and login to your page without a user name or password.
so the corect way to do it is using sessions?