Aug 1, 2000, 12:03 PM
Post #2 of 2
sure.. i'll take a stab..
i tend to do things by hand, though nowadays directly implementing the http is sorta frowned on.
in order to set the cookie, do this:
print "Set-Cookie: uname=UserName; path=/; domain=.whatever.com\r\n";
print "Set-Cookie: pass=thepassword; path=/; domain=.whatever.com\r\n";
you should do that *just* before you set the content type:
print "Content-type: text/html\n\n";
note that if you don't set an expiration date, the cookie is 'volatile' and is erased when the browser is closed. if you DO set an expiration date, then the cookie will be written to the cookies.txt file, which may be an issue for you, since you're storing passwords. if that's the case, i strongly suggest you encrypt the password, using Crypt::CBC or something similar.
in order to get the cookies back to auto-fill the fields, you can use the CGI functions:
$username_cookie = CGI::cookie("uname");
$passwd_cookie = CGI::cookie("pass");
this will load the cookies into the specified locations, and you can then do whatever you want with them...
again, you may want to think twice before setting password cookies in plaintext...