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 >
Perl Script  |  2017-09-21  |  871b  |  42 lines

  1. #!/usr/local/bin/perl
  2.  
  3. # Script written by Ben Adida (benjamin@media.mit.edu) to interface
  4. # the Netscape Magic Cookies
  5.  
  6.  
  7. # This Procedure set_cookie takes a Name, a Value, a Path, and a length of time that
  8. # the cookie should remain active
  9.  
  10.  
  11. sub space_to_plus {
  12.     local($string)=$_[0];
  13.     $string=~ s/ /\+/g;
  14.     return $string
  15.     }
  16.  
  17. sub plus_to_space {
  18.     local($string)=$_[0];
  19.     $string=~ s/\+/ /g;
  20.     return $string
  21.     }
  22.  
  23. sub set_cookie {
  24.     local($name)=$_[0];
  25.     local($value)=&space_to_plus($_[1]);
  26.     print "Set-Cookie: $name=$value; path=/\n";
  27. }
  28.  
  29. sub get_cookies {
  30.     $HTTP_COOKIE=&plus_to_space($ENV{'HTTP_COOKIE'});
  31. }
  32.  
  33. sub get_variable {
  34.     local($cookies)=$_[0];
  35.     local($variable)=$_[1];
  36.     $cookies=~ m/$variable=(.*)/;
  37.     local($return_value)=$1;
  38.     $return_value=~ s/(.*);(.*)/$1/;
  39.     print "$return_value\n";
  40.     $return_value;
  41.     }
  42.