Martin Schneider wrote:
> I saw this on some pages and want to do the same:
>
> - On one page the user can login. Before that no cookie is set!
>
> - On the next page they set the cookie and show either the user data
> or a warning that the user has disabled cookies and should enable
> them.
>
> I wasn't able to set and text a cookie on the same page! How is it
> done?

Probably wasn't done on the same page.  Here's my guess at how these sites do that:

(1) User visits login page, no cookie is set.
(2) User enters username and password in the login page form, clicks the submit
button, and the login page form posts back to itself.
(3) The login page has logic at the top to check and see if the form has been
posted...if so it verifies the user's credentials, sets a cookie, and then redirects
to the first page of the application.
(4) The first page of the application (main menu or whatever) checks to see if a
cookie has been provided.  If not, it displays the warning that the user has
disabled cookies.

So, the app sets the cookie and then immediately redirects to the page that checks
the cookie.  To the end user it would appear that the cookie was set and checked in
the same page.  HTH...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to