Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem setting cookies

Status
Not open for further replies.

NigeW

Programmer
Jun 10, 2002
134
NZ
I am developing an admin tool for a sports club ( so someone other than myself can administer the competition details, i.e. add games and results, etc.

I am trying to use cookies and userID / password authentication to add a some form of security.

I have a script to do the following

1 Process the form data when the user signs in and check it against data in a text file.
2 If userID and password are correct then set cookies for both parameters.
3 Then perform ==> print "Location: admin_menu.cgi\n\n";

The issue I have is that the cookies are not being set and therefore I am looping between the logon page and the "back-end" page completing steps 1-3 above.

The excerpt of code I have for setting cookies is . . .

...
use CGI::Cookie;

$c = new CGI::Cookie(-name => "bp_username",
-path => "/",
-expires => "+10M",
-value => "$uname");

print "Set-Cookie: ",$c->as_string,"\n";

$c = new CGI::Cookie(-name => "bp_password",
-path => "/",
-expires => "+10M",
-value => "$pw");

print "Set-Cookie: ",$c->as_string,"\n";
print "Location: admin_menu.cgi\n\n";

Can anyone please advise where I am going wrong.

I am new to CGI programming so any suggestions for improvement will also be gratefully received.

Thanks

Nige (kiwi bloke !)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top