in reply to Re: Perl reading Cookies Set by Javascript
in thread Perl reading Cookies Set by Javascript

Unfortunately I need to use JS to set the cookie because it is built up of dynamic elements on the page.

The Cookie is definitely being set and I am aware that JS cookies may be incompatible (from reading the docs of some of the cookie libs out there).

I did not set the expires variable because I want the cookie to be only available for the session. I'll try setting the expire option.

Does JS not follow the correct cookie standard? I would imagine that it should and that if it did, Perl should be able to correctly see the cookie.

  • Comment on Re: Re: Perl reading Cookies Set by Javascript

Replies are listed 'Best First'.
Re: Re: Re: Perl reading Cookies Set by Javascript
by io (Scribe) on Jul 25, 2002 at 12:23 UTC

    Cookies are a browser thing really, there is no standard how to implement them. It's even more vage for javascript cookies.

    For debugging, check if you cookie is visible to javascript (a reload after you set it):

    alert(document.cookie);

    In your script, check if the cookie is available in the environment:

    print $ENV{'HTTP_COOKIE'};

    If the last example does display the cookie, something might be wrong with CGI.pm. An old version maybe?

      Actually, that's exactly what I had done, the alert displays a cookie and the $ENV{HTTP_COOKIE} is empty which lead me to believe that JS is creatimg the cookie correctly but perhaps this is not being communicated to the enviroment variable. I'm pretty sure it's the latest version of CGI.pm but i'll grab a fresh copy and try again.