🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: best.general
Article #330

Re: Javascript, SSI's, cookies

#330
From: Malcolm Hoar
Date: Fri, 12 Oct 2001 10:27
43 lines
2401 bytes
In article <9q5goq$2413$1@nntp1.ba.best.com>, inwap@best.com (Joe Smith) 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.

Et tu Joe.

That was my first reaction too.

>>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.

But the server can expand the SSI *before* the document
(including the JS) is sent to the client.

I think that SSI tags do often need to be on one line. So
it may be better to write this as:

document.write('
<!--#include file="/webadmin/home/pub/login/public_html/test.html" -->
');

However, I don't know enough about JS to be sure how multi-line
quoted string literals are handled. That may demand a tweak.

-- 
Malcolm Hoar
malch@malch.com
Kant spell Neetchie
Technical Details
Message-ID: <9q6gho$28qo$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!malch
References: <3BC60DBD.19B3E030@superkids.com> <9q5goq$2413$1@nntp1.ba.best.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-12 03:27:16 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!malch
From: malch@malch.com (Malcolm Hoar)
Newsgroups: best.general
Subject: Re: Javascript, SSI's, cookies
Date: Fri, 12 Oct 2001 10:27:12 GMT
Organization: Malch Enterprizes
Lines: 44
Distribution: best
Message-ID: <9q6gho$28qo$1@nntp1.ba.best.com>
References: <3BC60DBD.19B3E030@superkids.com> <9q5goq$2413$1@nntp1.ba.best.com>
NNTP-Posting-Host: adsl-64-172-54-82.dsl.snfc21.pacbell.net
X-Trace: nntp1.ba.best.com 1002882424 74584 64.172.54.82 (12 Oct 2001 10:27:04 GMT)
X-Complaints-To: abuse@best.com
NNTP-Posting-Date: Fri, 12 Oct 2001 10:27:04 +0000 (UTC)
X-Newsreader: News Xpress 2.01