I don't like how the code can be seen by all users if the wanted to. I
would also prefer something server side.
Is there a way I can use PERL to create a cookie in the same fashion?
Just put a call to a cgi script in the header or body of all web pages to
return the cookie info or set it if need be.
Thanks in advance
I suppose you can use SSI to include a CGI script that gets or sets a
cookie.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar> Danny wrote:
>> Is there a way I can use PERL to create a cookie in the same
>> fashion? Just put a call to a cgi script in the header or body of
>> all web pages to return the cookie info or set it if need be.
Gunnar> I suppose you can use SSI to include a CGI script that gets or sets a
Gunnar> cookie.
SSI cannot set cookies. The headers of an SSI are checked for
well-formedness, but otherwise mostly ignored (other than redirects).
This includes the cookie-setting information. THus, no cookies.
print "Just another Perl hacker,"; # the first
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Yes I am new to perl.
I cannot change the extensions of all of my html files.
So I need something that gets called automatically as the html page is
loaded.
I also need to pass a variable to and from the cgi script.
This needs to be done transparaently.
I would greatly appreciate your advice or perhaps some direction as to how
to go about this.
Thanks so much
Danny
See perldoc CGI! Your probably going to have to set the cookie with a cgi
script, so perhaps use the script and then redirect to your html page with
print redirect.
Good luck!
-Robin
> Is there a way I can use PERL to create a cookie in the same fashion?
> Just put a call to a cgi script in the header or body of all web pages to
> return the cookie info or set it if need be.
Assuming this is being done in a CGI script...
To set the cookie you want to send a Set-Cookie header to the browser.
Do a Google search on http headers to get the correct syntax. It will
look something like this:
print "Set-Cookie:SessionID=$session_id\n";
To get cookies, read the docs for CGI.pm.
Hmm.. You learn something new every day. :) Thanks, Randal!
> Yes I am new to perl.
That's okay. Note that your problem has nothing to do with the
programming language Perl.
> I cannot change the extensions of all of my html files. So I need
> something that gets called automatically as the html page is
> loaded.
That could still have been an SSI invoked script, provided that you
are able to modify the server configuration with e.g. an .htaccess
file. But now we know that SSI cannot be used for other reasons.
> I also need to pass a variable to and from the cgi script. This
> needs to be done transparaently.
Sorry, but it's not clear to me what you mean by that.
This group is for discussing Perl, so this thread is off topic here.
To increase your chances to get help, I would recommend that you post
in a more suitable group, such as comp.infosystems.www.authoring.cgi.
If you do, please try to include a better description of what it is
you are trying to accomplish. (Also, don't forget to study
http://www.thinkspot.net/ciwac/howtopost.html if you haven't posted to
comp.infosystems.www.authoring.cgi before.)
> I cannot change the extensions of all of my html files.
> So I need something that gets called automatically as
> the html page is loaded.
> I also need to pass a variable to and from the cgi script.
> This needs to be done transparaently.
You could do like what Sun did back in the early days of the www.
Instead of having URLs like http://www.sun.com/products/solaris.html
they had http://www.sun.com/show/products/solaris.html where
"show" is actually a CGI with an aliased name. The "show" program
used $ENV{PATH_TRANSLATED} to locate the plain HTML file. It then
added HTTP headers and HTML for navigation to everything it output.
-Joe
Scott> print "Set-Cookie:SessionID=$session_id\n";
Please. Space after the colon. That it "works" with some so-called
browsers doesn't mean it's correct.
Scott> To get cookies, read the docs for CGI.pm.
Or to set cookies, read the docs for CGI.pm, and then you wouldn't
have made your syntax mistake, because CGI.pm does it properly. :)
>>>>>>"Scott" == Scott Bryce <sbr...@scottbryce.com> writes:
>
>
> Scott> print "Set-Cookie:SessionID=$session_id\n";
>
> Please. Space after the colon. That it "works" with some so-called
> browsers doesn't mean it's correct.
I don't know if I learn more from lurking, or from having my posts
corrected! Thanks! That line came directly from one of my CGI scripts.
It "works" for IE, NS and Opera. I'll certainly make the correction!
btw, my latest post has some examples of cookies and CGI.pm...
-Robin