Cookies As Html In Perl

liunx

Guest
Hey ya'll..<br /><br />I recently updated one of my scripts to use cookies rather than form data to hold user info. After playing with it for a while, this was the solution I came up with. Just looking to see if there was a better way to do it.<br /><br />User gets to a login page, enters their info and hits submit.<br />Before any text is sent back, I check for this:<br />routines later verify this information is correct.<br />I had to add the 301 header because it was just dumping the user back to the login screen, seems you can't write and read a cookie on the same page load.<br />setCookie just formats and sends the Set-Cookie html header with the included data.<br /><br />if ($form{'username'}) { <br /> &setCookie("poduser", "$form{'username'}", "$form{'password'}", "$form{'storenum'}", $myCookieExpires, $myCookiePath, $myCookieDomain); <br /> print "Status: 301 Moved Permanantly\n";<br /> print "Location: <a href="http://www.pen411.com/cgi-bin/pod.cgi\n\n";" target="_blank">http://www.pen411.com/cgi-bin/pod.cgi\n\n";</a><br /><br />}<br /><br />here was the same deal, without the 301, it left the user at the last screen they were at until they tried to do something, then it realized they were logged out and dumped them back to the login screen.<br /><br />if ($form{'action'} eq 'logout') { <br /> &setCookie("poduser", "", "", "", "now", $myCookiePath, $myCookieDomain); <br /> $loggedin = 0;<br /> print "Status: 301 Moved Permanantly\n";<br /> print "Location: <a href="http://www.pen411.com/cgi-bin/pod.cgi\n\n";" target="_blank">http://www.pen411.com/cgi-bin/pod.cgi\n\n";</a><br /><br />Any thoughts or suggestions are welcome, as this seems a clumsy way to make this work right.<!--content-->
 
Top