Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting cookies and server-side includes (SSI)

404 views
Skip to first unread message

havoc

unread,
Jul 28, 2001, 11:13:05 AM7/28/01
to
I'm just confused, and I don't know what to do about it...

I have a script that refreshes a cookie *every time* it's loaded. (It
checks the existing cookie, then refreshes is for various reasons.) The
problem is that the script is originally loaded with an SSI <!--#include
virtual="/cgi-bin/script.cgi"-->. When this happens, the existing cookie
is read from the browser, but since the headers have already been sent
by index.shtml, apparenlty Apache is discarding the
header(-cookie=>[$cookie]) directive.

Anybody got any ideas on what I can do to get around this? I really
don't like "splash screens," and I'd like to keep the script as standard
as possible for using default server installations without having to
force my users to reconfigure their server (since most people don't
know, don't care and don't have access to reconfigure their httpd
anyway).

thoughts?

havoc

*****=======| http://bigpig.org/
*****=======|
*****=======| It's about Freedom!
============|
LlamaZfo
--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

Keith Szlamp

unread,
Aug 1, 2001, 4:46:19 PM8/1/01
to

: I have a script that refreshes a cookie *every time* it's loaded. (It

: checks the existing cookie, then refreshes is for various reasons.) The
: problem is that the script is originally loaded with an SSI <!--#include
: virtual="/cgi-bin/script.cgi"-->

: Anybody got any ideas on what I can do to get around this?

Your right when you say the SSI is making the cookies get discarded, because
cookies have to be set as part of the header, and unfortunately, your header
is already completed by the time your SSI is triggered, so any cookies set
with the SSI will be futile.

I would simply create a script to run instead of the SSI, (so have index.cgi
instead of index.shtml or set a .htaccess directive and get all .phtml files
to be parsed as scripts, and call it index.phtml instead) thus getting the
script to output the page you require.. something like so...

=== START ===

#!/usr/bin/perl -w
##################################
# Set Session Cookie as page loads Script #
##################################
# start header. notice only one \n character so as
# not to tell the browser we have finished
# the header
print "content-type: text/html\n";

# set cookie
print "Set-Cookie: name=value; path=/; domain=www.yourdomain.com;\n";

# finish header
print "\n";

# print page
print <<EOM;
<HTML>
<HEAD>
<TITLE>Your Page</TITLE>
</HEAD>
<BODY>
<P>Your Page goes here</P>
</BODY>
</HTML>
EOM
exit;

== END ==

I hope you can work something out from that... if you need any more help -
email me...

http://szlamp.com/

0 new messages