- 论坛徽章:
- 1
|
用perl作为cgi编程如何实现认证?
用cookie....
sub COOK {
$username=$cookies{"username"};
$password=$cookies{"password"};
}
sub GETCOOK {
%cookies = map split(/=/), split(/; /,$ENV{'HTTP_COOKIE'});
}
## 設定COOKIE
sub SETCOOK
{
$thePath = '/';
$theDomain = '.com.tw'; #每一台web server之設定皆不同
$exp_now = 'Wednesday, 09-Nov-90 23:12:40 GMT';
$exp_later = '+30m';
$eol = "\015\012";
print "HTTP/1.0 200 OK$eolServer: MacHTTP$eolContent-type: text/html$eol";
print "Set-Cookie:username=$username; path=$thePath$eol";
print "Set-Cookie:password=$password; path=$thePath$eol";
} |
|