weversbv
asked on
Cookie question
Why will this set-cookie action not work on a NT machine?
print "Set-Cookie: $key=$value; expires=$expires; path=\; domain=$domain \n";
Set-Cookie: ProtectSessionIDAdmin=3ba0 cb4207ccd4 2c; expires=Friday, 14-Sept-2001 16:07:43 GMT; path=; domain=.pro-hosting.co.uk;
This will work on UNIX but not on NT (Windows2000)??
How to make it work on NT (Windows2000)??
print "Set-Cookie: $key=$value; expires=$expires; path=\; domain=$domain \n";
Set-Cookie: ProtectSessionIDAdmin=3ba0
This will work on UNIX but not on NT (Windows2000)??
How to make it work on NT (Windows2000)??
* first try to leave out the domain in your cookie line
also be sure to send a \n\n at the LAST line of your set-cookie
otherwise it won't be accepted in the browser..
OR
you could use the cookie function that is implemented in CGI module;
eg.
---->8------------------>8 ---------- -->8------ --
use CGI qw(:standard);
$cookie= $form->cookie(-name=>cartn umber',
-value=>"$cart",
-domain=>"me.com",
-path=>"/");
print $form->header(-cookie=>$co okie);
---->8------------------>8 ---------- -->8------ --
it will write a standard HTML header containt the cookie, no need to write "Content-type: text/html\n\n" at the end, the form header will write it correctly..
also be sure to send a \n\n at the LAST line of your set-cookie
otherwise it won't be accepted in the browser..
OR
you could use the cookie function that is implemented in CGI module;
eg.
---->8------------------>8
use CGI qw(:standard);
$cookie= $form->cookie(-name=>cartn
-value=>"$cart",
-domain=>"me.com",
-path=>"/");
print $form->header(-cookie=>$co
---->8------------------>8
it will write a standard HTML header containt the cookie, no need to write "Content-type: text/html\n\n" at the end, the form header will write it correctly..
weversbv,
"..Why will this set-cookie action not work on a NT machine?..."
Please clarify what exact does/does not happen.
Is the cookie not set at all?? If yes, then how can you conclusively confirm that?
Does is print your cookie on the screen?
Can you please post the entire code here?
What browser are you using (IE or NS or both)?
That will help you get a more accurate answer, faster.
"..How to make it work on NT (Windows2000)?? ."
Here is a teeny tiny script that you can try on your Win* box.
To confirm if the cookie is being set properly, remember to enable "Warn before setting cookie" option in your browser.
Let me know how this script works for you.
============set_cookie.pl
$DOMAIN=".somehost.com";
## Set a Domain Cookie with no expiration date.
print "Set-Cookie: back=yes; domain=$DOMAIN; path=/; \n";
print "Content-type: text/html\n\n";
print "<h2> Cookie has been set!!</H2>\n";
"..Why will this set-cookie action not work on a NT machine?..."
Please clarify what exact does/does not happen.
Is the cookie not set at all?? If yes, then how can you conclusively confirm that?
Does is print your cookie on the screen?
Can you please post the entire code here?
What browser are you using (IE or NS or both)?
That will help you get a more accurate answer, faster.
"..How to make it work on NT (Windows2000)?? ."
Here is a teeny tiny script that you can try on your Win* box.
To confirm if the cookie is being set properly, remember to enable "Warn before setting cookie" option in your browser.
Let me know how this script works for you.
============set_cookie.pl
$DOMAIN=".somehost.com";
## Set a Domain Cookie with no expiration date.
print "Set-Cookie: back=yes; domain=$DOMAIN; path=/; \n";
print "Content-type: text/html\n\n";
print "<h2> Cookie has been set!!</H2>\n";
> Why will this set-cookie action not work on a NT machine?
>
> print "Set-Cookie: $key=$value; expires=$expires; path=\; domain=$domain \n";
You put backslash instead of slash. should be "path=/;"
>
> print "Set-Cookie: $key=$value; expires=$expires; path=\; domain=$domain \n";
You put backslash instead of slash. should be "path=/;"
ASKER
ASKER
? no text ?
ASKER
ASKER
It is not possible to add a comment!!!
ASKER
ASKER
The back slash did not work!!
ASKER
The back slash did not work!!
you should put a slash for the path, like path=/ or path=/dir/
also, if the Set-Cookie is the last header line sent before html, make sure that you have \n\n at the end of the line
also, if the Set-Cookie is the last header line sent before html, make sure that you have \n\n at the end of the line
ASKER
The back slash did not work!!
you mean browser doesn't accept the cookie?
ASKER
What is the use of path and what should be entered at dir??
ASKER
I does accept cookies but I want to change the expiration date of the cookie! It can be set onces but not be changed????
In most of the case you'll leave it path=/ , this means that the browser must send the cookie when requesting
any file located anywhere in the directory structure of your website. if this cookie is used only for administration
purposes, for example, you're using this to login an admin account to the content management system, you can
put in the path only the location of the protected directory, for example, path=/admin/
any file located anywhere in the directory structure of your website. if this cookie is used only for administration
purposes, for example, you're using this to login an admin account to the content management system, you can
put in the path only the location of the protected directory, for example, path=/admin/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
domain=www.pro-hosting.co.uk;
or
domain=http://www.pro-hosting.co.uk;