home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet 1996 World Exposition
/
park.org.s3.amazonaws.com.7z
/
park.org.s3.amazonaws.com
/
Pavilions
/
BrainOpera
/
cgi-bin
/
cookies.pl
< prev
next >
Wrap
Perl Script
|
2017-09-21
|
871b
|
42 lines
#!/usr/local/bin/perl
# Script written by Ben Adida (benjamin@media.mit.edu) to interface
# the Netscape Magic Cookies
# This Procedure set_cookie takes a Name, a Value, a Path, and a length of time that
# the cookie should remain active
sub space_to_plus {
local($string)=$_[0];
$string=~ s/ /\+/g;
return $string
}
sub plus_to_space {
local($string)=$_[0];
$string=~ s/\+/ /g;
return $string
}
sub set_cookie {
local($name)=$_[0];
local($value)=&space_to_plus($_[1]);
print "Set-Cookie: $name=$value; path=/\n";
}
sub get_cookies {
$HTTP_COOKIE=&plus_to_space($ENV{'HTTP_COOKIE'});
}
sub get_variable {
local($cookies)=$_[0];
local($variable)=$_[1];
$cookies=~ m/$variable=(.*)/;
local($return_value)=$1;
$return_value=~ s/(.*);(.*)/$1/;
print "$return_value\n";
$return_value;
}