View Full Version : javascript cookies/perl problem

12-06-2004, 12:12 PM
okay so i got a login that sends its name/password to a perl script which looks up the names and passwords in a text file, and if a name and password is correct, it sets a cookie called user with the value of the user name. Now I know this is riddiculously insecure but im just getting started and eventually ill have it better. BUT the cookie can only be accessed by html pages that are in the cgi-bin folder, not the root folder. Soo how do i get around that?
Took me 2 hours to figure out why the cookie kept coming up as null. Any help is appreciated, i think ive met my match.

Willy Duitt
12-06-2004, 12:28 PM
You need to set the domain and the path to root to have the cookie read site wide...

var date = new Date();
date.setTime(date.getTime() + 365*24*60*60*1000);
var expString = '; expires = '+date.toGMTString();
expString += '; domain = '+location.host+'; path=\/;'