[San-diego-pm] Cookie problem

Cameron Childress cameronc at mindspring.com
Thu Jul 15 18:03:15 CDT 2004


> 1. Are you saying I can't set the cookie and then check for its existence?

In each web page request, the browser sends along information such as what
page it's requesting, what type of browser it is, what the referrer was, and
any cookies set for that domain.

When the webserver responds, it has the opportunity to send back data too,
including the content of the page, and other HTTP headers, cookies being a
type of HTTP header.

So the transaction would have to go like this:

1) Browser requests page from your server
2) Server sends back page, plus one HTTP cookie header
3) Browser requests another page (or is redirected to another page) and
sends the cookie back with the request.
4) Server receives the request (which now includes cookie data) and
processes it accordingly.

> 2. My understanding is that a common way to learn if cookies are
> disabled in a browser is by setting one and then reading it.

As several people have said, you can't do that without two separate
requests.  In a login situation where you need to track state after login, I
typically set the cookie on the page containing the login form, and attempt
to read it in the login script itself.  This process can be done with
anything where you know the session has to start being tracked when X
happens (add to cart, select options, or login).

You can also issue an HTTP or meta redirect and force the user to hit the
server a second time.  I usually don't favor this option for high volume
sites because of the increased traffic it generates.  Most sites, however,
are not high volume.

-Cameron

-----------------
Cameron Childress
Sumo Consulting Inc
http://www.sumoc.com
---
land:  858.509.3098
cell:  678.637.5072
aim:   cameroncf
email: cameronc at mindspring.com

> -----Original Message-----
> From: san-diego-pm-bounces at pm.org [mailto:san-diego-pm-bounces at pm.org]On
> Behalf Of Joel Fentin
> Sent: Thursday, July 15, 2004 2:51 PM
> To: Chris Radcliff
> Cc: San Diego Perl Mongers
> Subject: Re: [San-diego-pm] Cookie problem
>
>
> Chris Radcliff wrote:
> > Hi Joel,
> >
> > Cookies are sent with the result of your request (in the headers) and
> > read on the next request. The cookies you read on any given request
> > will only be those set previously, so you'll want to keep track of the
> > values internally as well.
> >
> > Cheers,
> > ~chris
>
> I have read and and re-read the above, and I don't get it.
>
> 1. Are you saying I can't set the cookie and then check for its existence?
>
> 2. My understanding is that a common way to learn if cookies are
> disabled in a browser is by setting one and then reading it.
>
> 3. You did not say there was an error in my code.
>
> 4. I am still stuck at this point.
>
> --
> Joel Fentin    tel: 760-749-8863    FAX: 760-749-8864
> Contact me:    http://fentin.com/me/ContactMe.html
> Biz:           http://fentin.com
> Personal:      http://fentin.com/me/
>
> _______________________________________________
> San-diego-pm mailing list
> San-diego-pm at pm.org
> http://www.pm.org/mailman/listinfo/san-diego-pm
>




More information about the San-Diego-pm mailing list