A rchive Date
[ 10-06-2000 ]
Category
[ Information Technologies ]
sub-Categoy
[ Networking ]
|
[Retrieving cookies with PERL
On platforms that support the environment variable $ENV{'HTTP_COOKIE'} (such as Solaris), cookies can be read into PERL with that environment variable.
As with JavaScript, the returned value is valid name-value pairs for this document, separated by semicolons. Again, it is simpler to write a parsing routine for this header:
@nvpairs=split(/; /, $ENV{'HTTP_COOKIE'});
foreach $pair (@nvpairs) {
($name, $value) = split(/=/, $pair);
$cookie{$name} = $value;
}
A call would be like:
$myVar = $cookie{'foo'};
Here, myVar would equal bar.
5.4 Retrieving cookies with LiveWire
To retrieve cookies into LiveWire, again use the client object. Any cookies headed with the prefix NETSCAPE_LIVEWIRE will be made into methods of the client object. Thus, any methods on the client object that have not expired from the previous session will still be available.
myVar = client.foo;
Here, myVar would equal bar.
5.5 Retrieving cookies with Active Server Pages
To retrieve cookies into ASP, use the Request.Cookies object. All the cookies valid for this document are pre-parsed into this object for you for quick and easy access.
So, all you need to do to access a value is simply write:
myVar = Request.Cookies("foo")
Again, myVar equals bar. ]
|