Re: [PHP] Cookies page refresh

2006-12-17 Thread Chris Shiflett
Richard Lynch wrote:
 A cookie is sent BACK to the server after the server sends
 it to the browser. Period.
 
 It's kind of like when you go to a movie, and you buy your
 ticket from one person, and then you hand it to another,
 and they hand it back, and then you have to be prepared to
 show it to prove you aren't sitting through a second movie.
 
 Walking back out front to the ticket sales window, you don't
 show them your ticket again...
 
 Maybe that's not such a good analogy...

You could fix it by explaining that no one should check to see whether
you have a ticket before you've had a chance to buy one. The timing just
doesn't make sense.

Developers sometimes make the mistake of checking $_COOKIE (a convenient
representation of the Cookie header from the previous request) before a
Set-Cookie header has been sent to the browser. The browser can't return
something it has never received.

Chris

-- 
Chris Shiflett
http://shiflett.org/

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



Re: [PHP] Cookies page refresh

2006-12-15 Thread Richard Lynch
A cookie is sent BACK to the server after the server sends it to the
browser.  Period.

It's kind of like when you go to a movie, and you buy your ticket from
one person, and then you hand it to another, and they hand it back,
and then you have to be prepared to show it to prove you aren't
sitting through a second movie.

Walking back out front to the ticket sales window, you don't show them
your ticket again...

Maybe that's not such a good analogy...

Anyway, when you hit the back button, back to the first page, there is
no cookie, because there was no cookie in that request, because you
hadn't sent it.

If you reload, you get back the cookie, because the browser has it, so
it can send it now.

On Tue, December 12, 2006 9:28 am, William Stokes wrote:
 Hello,

 I have a page that uses session cookies for deciding what content to
 show to
 a visitor. User also has 2 form objecks to apply filters to the
 content SQL
 queries. So at the beginning of the script I set 2 cookies based on
 user
 selections(or defaults) and after that make DB query based on user
 selections. I wanted to use cookies because there also back - up -
 forward links for pagination.

 Problem is that in order to get the cookie based system to work the
 page
 needs a refresh to read the cookies and display content corretly. Is
 this
 because the page loads faster than the server set's the cookies to
 client
 browser? If so what's the corrert / best way to implement the
 filters and
 page navigation if there's 2 form select lists and 3 links to navigate
 the
 page.

 Thanks
 -Will

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Cookies page refresh

2006-12-12 Thread Peter Lauri
Hi,

I think it says somewhere in the documentation that the cookie values will
not be available until next request/response...

/Peter


-Original Message-
From: William Stokes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 12, 2006 5:28 PM
To: php-general@lists.php.net
Subject: [PHP] Cookies  page refresh

Hello,

I have a page that uses session cookies for deciding what content to show to

a visitor. User also has 2 form objecks to apply filters to the content SQL 
queries. So at the beginning of the script I set 2 cookies based on user 
selections(or defaults) and after that make DB query based on user 
selections. I wanted to use cookies because there also back - up - 
forward links for pagination.

Problem is that in order to get the cookie based system to work the page 
needs a refresh to read the cookies and display content corretly. Is this 
because the page loads faster than the server set's the cookies to client 
browser? If so what's the corrert / best way to implement the filters and 
page navigation if there's 2 form select lists and 3 links to navigate the 
page.

Thanks
-Will

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

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



Re: [PHP] Cookies page refresh

2006-12-12 Thread Chris

William Stokes wrote:

Hello,

I have a page that uses session cookies for deciding what content to show to 
a visitor. User also has 2 form objecks to apply filters to the content SQL 
queries. So at the beginning of the script I set 2 cookies based on user 
selections(or defaults) and after that make DB query based on user 
selections. I wanted to use cookies because there also back - up - 
forward links for pagination.


Problem is that in order to get the cookie based system to work the page 
needs a refresh to read the cookies and display content corretly. Is this 
because the page loads faster than the server set's the cookies to client 
browser? If so what's the corrert / best way to implement the filters and 
page navigation if there's 2 form select lists and 3 links to navigate the 
page.


Use a session variable instead. Otherwise I could modify the cookie and 
change the query / queries being run really easily... causing sql 
injection and a bunch of other issues.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Cookies page refresh

2006-12-12 Thread William Stokes
Thanks.

It seems that I tested the right things but in a wrong order...

-Will

Chris [EMAIL PROTECTED] kirjoitti 
viestissä:[EMAIL PROTECTED]
 William Stokes wrote:
 Hello,

 I have a page that uses session cookies for deciding what content to show 
 to a visitor. User also has 2 form objecks to apply filters to the 
 content SQL queries. So at the beginning of the script I set 2 cookies 
 based on user selections(or defaults) and after that make DB query based 
 on user selections. I wanted to use cookies because there also back - 
 up - forward links for pagination.

 Problem is that in order to get the cookie based system to work the page 
 needs a refresh to read the cookies and display content corretly. Is this 
 because the page loads faster than the server set's the cookies to client 
 browser? If so what's the corrert / best way to implement the filters 
 and page navigation if there's 2 form select lists and 3 links to 
 navigate the page.

 Use a session variable instead. Otherwise I could modify the cookie and 
 change the query / queries being run really easily... causing sql 
 injection and a bunch of other issues.

 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/ 

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