http://www.perlmonks.org?node_id=184440

hotshot has asked for the wisdom of the Perl Monks concerning the following question:

I create and modified a cookie with a javascript. I'm trying to fill the cookie with Xml page. On the server side, while CGI.pm reads the enviroment variable: HTTP_COOKIE, only the first line appear ...

Is there any problem to pass Xml page through Cookie ?

Thanks.

Hotshot

Replies are listed 'Best First'.
Re: XML & Cookies
by erasei (Pilgrim) on Jul 23, 2002 at 15:38 UTC
    If you are passing a large amount of XML data into the cookie it might be the problem. According to Cookie Central's FAQ there is a 4k size limit on HTTP Headers, which Cookies are a part of. Granted, 4k is massive for a header, but, passing XML data via a cookie could hit that pretty easily I suppose.

    As I stated as a reply to your other post today there might be other ways of accomplishing that you are after. Having XML stored locally could get really out of hand from a security stand point.

    How about you give us a full overview of what you are trying to do, and we will offer you some advice on the best way to do it overall.

      there is a 4k size limit on HTTP Headers, which Cookies are a part of.

      And depending on the browser on the client side you won't even have 4k.
      I can't remember if it was netscape 4 or IE 5, but one of them stored only up to 1k. Anoying behaviour, as the cookie-content was carefully crafted not to exceed 4k, but relied on having at least that much

      Just to share the experience ;-)
      regards,
      Tomte
      the thing I'm trying to do is filling a client page with user's data (using JavaScript) and send it back to the server through a cookie using XML format, the volume of the user's data is quite big(but yet less then 4k !!!) so I prefer to send it via cookie instead of POST or GET in order to achieve faster performances

      Thanks.

      Hotshot
Re: XML & Cookies
by tmiklas (Hermit) on Jul 23, 2002 at 15:40 UTC
    Hi!

    Following perldoc CGI: To retrieve a cookie, request it by nameb y calling cookie() method without the -value parameter:
    use CGI; $query = new CGI; $riddle = $query->cookie('riddle_name');
    It works for me...

    BTW. Remember of 4k limit on HTTP headers...

    Greetz, Tom.
Re: XML & Cookies
by simeon2000 (Monk) on Jul 23, 2002 at 15:42 UTC
    I would be wary of using XML in cookies. XML is not the most compact way to store data, and if I recall correctly, there IS a space constraint to the length of cookies. There is some standard, but in all reality it is probably browser-dependent.

    Technically, I believe you could pass XML as a big long string as a cookie param, but I can think of many better ways of accomplishing the task.

    "Falling in love with map, one block at a time." - simeon2000