CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Set-Cookie troubles.

 



muinatit
Deleted

Feb 5, 2001, 4:27 PM

Post #1 of 2 (263 views)
Set-Cookie troubles. Can't Post

I have a small utility script that I'm working on for another person. It's coded to set a cookie when a person logs in. But when I do a test login, appearing on my screen is 1,000s of Set-Cookie things. Here should be all of the code invovled:


Code
print "Content-Type: text/html\n\n"; 

###
sub login {
###
if ($input{'login'} != 1) {
open (LOG, "login.html") || die "login.html: $!";
print $_ while (<LOG>);
close (LOG);
exit;
} elsif ($input{'login'} == 1) {
die "Invalid login" if ("$input{'usr'}:$input{'pwd'}" ne $admin);
print "Set-Cookie: usr=$input{'usr'}; expires=Tue, 04-Oct-2061 12:00:00 GMT;\n";
print "Set-Cookie: pwd=$input{'pwd'}; expires=Tue, 04-Oct-2061 12:00:00 GMT;\n";
&main;
}
}

# Stuff below just produces temp. output

###
sub main {
###
&GetCookies;
&login if ("$cookie{'dir_usr'}:$cookie{'dir_pwd'}" ne $admin);
$htpasswd = CheckPath($htpasswd); # Clear $htpasswd of in securitys.
print "<html><head><title>usermanage</title></head><body>\n";
open (PWD, "$htpasswd") || die "$htpasswd: $!";
print $_ while (<PWD>);
close (PWD);
print "</body></html>";
exit;
}

muinatit
muinatit@hotpop.com


parham_m_s
journeyman

Feb 5, 2001, 6:29 PM

Post #2 of 2 (260 views)
Re: Set-Cookie troubles. [In reply to] Can't Post

set your cookies before you define what type of file is generated...

do this:

print "Set-Cookie: usr=$input{'usr'}; expires=Tue, 04-Oct-2061 12:00:00 GMT;\n";
print "Set-Cookie: pwd=$input{'pwd'}; expires=Tue, 04-Oct-2061 12:00:00 GMT;\n";

before you do this:

print "Content-Type: text/html\n\n";


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives