Dear fellow robed ones,

This is not the typical why can't I set a cookie using an SSI script? question and really I've spent a couple of hours browsing already without success.

I already know that you cannot set a cookie with an SSI script and I think I understand why - the set cookie command has to go before the headers and the SSI content is generated by the server and put below those headers.

However, I only need to use an existing cookie in an SSI script. I have read that the SSI script cannot use the cookie environment variable because the server runs the script without reference to the incoming cookie. In fact, I think I've verified this because I've tried to use it in my SSI and it took me a long time to work out why my script wasn't working. (I don't fully understand why this should be so - the cookie is sent to the server and so I would have thought that there ought to be a way for the SSI script to use what the server already knows).

Anyway, to cut to the chase - I am after any method of working around this while still using my SSI scripts. One workaround is to simply generate the whole page, of course. I can do that but that means changing the page names and is therefore not an option for me unfortunately.

While searching the web, I have seen snippets of information that imply it IS possible to workaround this using javascript and using PHP. I don't know these but am willing to learn if necessary. However, I gathered that javascript was spawn of the devil. And I thought that PHP could only be used to generate WHOLE pages and if so, that is not an option again. Anyway, the snippets were not understandable to me. Maybe someone can explain them in more detail for l'il ol' me. Can something be done in Java? (not that I know that either)

Or is it possible in any way to make the cookie variable appear within the HTML and therefore pass that parameter through as an argument to my SSI script?

Gosh, this is frustrating as I've done a lot of work which is tested and working and finished and now it will all be wasted if I cannot get hold of this cookie variable within the script.

I can give you the details of what my script is doing if you like but did not want to waste your time as the question is really a generic one, not a specific thing.

Any advice or tips appreciated...

thanks,

A pitiful and desperate monk.

In reply to SSI and *reading* a cookie only by jfrm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.