Gossamer Forum
Home : General : Perl Programming :

Cookies, damn cookies

Quote Reply
Cookies, damn cookies
Currently I use a javascript to embed a cookie in a SSI page:

print "Content-type: text/html\n\n";
print "<script language=\"javascript\">\n";
print " document.cookie = \"id=valid; path=/\"\n";
print "</script>\n";

The script outputs the cookie js to the SSI page and is called as:

<!--#exec cgi="/cgi-bin/script.cgi"-->

Question is, is there a better way to do this without javascript? But it has to be via the script.

Dan Smile
Quote Reply
Re: Cookies, damn cookies In reply to
It is possible to set cookies via the script before sending the content-type header. Try using cookie-lib.pl.

------------------
Charles Capps
http://solareclipse.net/
Quote Reply
Re: Cookies, damn cookies In reply to
Thanks Charles. But it does not seem to work when the script is called in SSI. What I've done instead is insert a meta Set-Cookie command:

print "Content-type: text/html\n\n";
print "<meta HTTP-EQUIV=\"Set-Cookie\" content=\"id=valid; path=/\">\n";

This works as expected.

Dan Smile


Quote Reply
Re: Cookies, damn cookies In reply to
Ah, forgot that SSI sends the content-type header first.

------------------
Charles Capps
http://solareclipse.net/
Quote Reply
Re: Cookies, damn cookies In reply to
Right on target. However, given that we are talking SSIs, the meta set-cookie commands do the trick. I always forget about the power of meta tags.

Dan Smile