I can't seem to set cookies in Perl no matter what.
These are the two ways I 've tried:
1) using CGI.pm
$cookie = $query->cookie(-name=>'DemoName',
-value=>'success',
-expires=>'+4h',
-path=>'/');
print $query->header(-cookie=>$cookie);
but all that does is print this at the start of the page:
Set-Cookie: DemoName=success; path=/; expires=Wed, 11-Apr-2007 15:48:20 GMT
Date: Wed, 11 Apr 2007 11:48:20 GMT
Content-Type: text/html; charset=ISO-8859-1
2) I have also tried using javascript:
<SCRIPT>
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) \? argv[2] : null;
var path = (argc > 3) \? argv[3] : null;
var domain = (argc > 4) \? argv[4] : null;
var secure = (argc > 5) \? argv[5] : false;
document.cookie = name + \"=\" + escape (value) +
((expires == null) ? \"\" : (\"; expires=\" + expires.toGMTString())) +
((path == null) \? \"\" : (\"; path=\" + path)) +
((domain == null) \? \"\" : (\"; domain=\" + domain)) +
((secure == true) \? \"; secure\" : \"\");
}
var uname = 'success';
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
SetCookie('DemoName', uname, expdate);
</SCRIPT>
this script works perfectly in a normal html file, but just doesn't work when it's its returned with html in perl!!
please help!!! I am completely bewildered!!!!
These are the two ways I 've tried:
1) using CGI.pm
$cookie = $query->cookie(-name=>'DemoName',
-value=>'success',
-expires=>'+4h',
-path=>'/');
print $query->header(-cookie=>$cookie);
but all that does is print this at the start of the page:
Set-Cookie: DemoName=success; path=/; expires=Wed, 11-Apr-2007 15:48:20 GMT
Date: Wed, 11 Apr 2007 11:48:20 GMT
Content-Type: text/html; charset=ISO-8859-1
2) I have also tried using javascript:
<SCRIPT>
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) \? argv[2] : null;
var path = (argc > 3) \? argv[3] : null;
var domain = (argc > 4) \? argv[4] : null;
var secure = (argc > 5) \? argv[5] : false;
document.cookie = name + \"=\" + escape (value) +
((expires == null) ? \"\" : (\"; expires=\" + expires.toGMTString())) +
((path == null) \? \"\" : (\"; path=\" + path)) +
((domain == null) \? \"\" : (\"; domain=\" + domain)) +
((secure == true) \? \"; secure\" : \"\");
}
var uname = 'success';
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
SetCookie('DemoName', uname, expdate);
</SCRIPT>
this script works perfectly in a normal html file, but just doesn't work when it's its returned with html in perl!!
please help!!! I am completely bewildered!!!!