in reply to reading and writing a CGI cookie in the same page

can't you create and read a cookie in the same pageview?

Not without some javascript trickery, or a redirect to yourself.

  • Comment on Re: reading and writing a CGI cookie in the same page

Replies are listed 'Best First'.
Re: Re: reading and writing a CGI cookie in the same page
by PodMaster (Abbot) on Feb 21, 2003 at 02:20 UTC
    Forget javascript trickery (as a "helper" javascript rocks, but you can't rely on it so don't rely on it from the beginning).

    It is best to do a redirect (some might call it standard practice). See merlyns article on Basic Cookie Management.

    Basic strategy is

    • user visits foo.cgi
    • you try to set a cookie whilst redirecting to foo.cgi?redirect=1
    • if you can read cookie, do your thing, if not, user don't support cookies, so don't redirect again (redirect=1 to prevent an infinite loop)


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.