Article View: best.general
Article #329Re: Javascript, SSI's, cookies
From: Joe Smith
Date: Fri, 12 Oct 2001 01:24
Date: Fri, 12 Oct 2001 01:24
39 lines
2445 bytes
2445 bytes
In article <3BC60DBD.19B3E030@superkids.com>,
Andrew Maisel <andrew@superkids.com> wrote:
>Is there a way to use javascript or an SSI to read a [session] cookie,
>then include a header file depending on the presence or absence or value
>of that cookie? (rather than using a cgi script)
SSI (Server Side Includes) have to be done on the server, NOT on
the browser.
>When I try this with javascript, I run into a problem when the script
>tries to do the include -- if the contents of the file to be included is
>more than one line long, the document.write command apparently chokes.
>Although the file contents show up in the source, the browser does not
>show it.
>
>javascript snippet
>---------------------
>var foo = getCookie('foo');
>getCookie('foo');
>if (foo == 'red') {
> document.write('<!--#include
>file="/webadmin/home/pub/login/public_html/test.html" -->');
That tells JavaScript running on the browser to put an angle bracket,
exclamation point, two hyphens, a pound sign and other stuff in
the browser's cache. The BESTWWWD never sees that string.
SSIs have to exist in the *.shtml file on the server in order for
the server to do anything with it.
>Alternatively, I'm wondering if there is a way to do this without
>javascript, by just using a conditional expression in an SSI...
Apache has directives which can be conditional on env vars, but
BESTWWD does not. As long as you are using Best's web server, CGI
is your only option.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
Technical Details
Message-ID:
<9q5goq$2413$1@nntp1.ba.best.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news1.best.com!nntp1.ba.best.com!inwapReferences:
<3BC60DBD.19B3E030@superkids.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9f6d,e3a236c74c55f283 X-Google-Attributes: gidf9f6d,public X-Google-ArrivalTime: 2001-10-11 18:24:48 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news1.best.com!nntp1.ba.best.com!inwap From: inwap@best.com (Joe Smith) Newsgroups: best.general Subject: Re: Javascript, SSI's, cookies Date: Fri, 12 Oct 2001 01:24:42 +0000 (UTC) Organization: Chez Inwap Lines: 39 Distribution: best Message-ID: <9q5goq$2413$1@nntp1.ba.best.com> References: <3BC60DBD.19B3E030@superkids.com> NNTP-Posting-Host: shell3.ba.best.com X-Trace: nntp1.ba.best.com 1002849882 69667 206.184.139.134 (12 Oct 2001 01:24:42 GMT) X-Complaints-To: abuse@best.com NNTP-Posting-Date: Fri, 12 Oct 2001 01:24:42 +0000 (UTC)