Solved

Cookie question

Posted on 2001-09-13
19
173 Views
Last Modified: 2010-03-05
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=3ba0cb4207ccd42c; 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)??
0
Comment
Question by:weversbv
19 Comments
 
LVL 6

Expert Comment

by:holli
ID: 6480611
0
 

Expert Comment

by:justroll
ID: 6481178
* 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=>cartnumber',
                                  -value=>"$cart",
                                  -domain=>"me.com",
                                  -path=>"/");

    print $form->header(-cookie=>$cookie);

---->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..

0
 
LVL 16

Expert Comment

by:maneshr
ID: 6481411
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";

0
 
LVL 1

Expert Comment

by:vahan
ID: 6481531
> 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=/;"

0
 

Author Comment

by:weversbv
ID: 6481702
0
 

Author Comment

by:weversbv
ID: 6481718
0
 
LVL 1

Expert Comment

by:vahan
ID: 6481721
? no text ?
0
 

Author Comment

by:weversbv
ID: 6482110
0
 

Author Comment

by:weversbv
ID: 6482113
It is not possible to add a comment!!!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:weversbv
ID: 6482114
0
 

Author Comment

by:weversbv
ID: 6482118
The back slash did not work!!
0
 

Author Comment

by:weversbv
ID: 6482142
The back slash did not work!!
0
 
LVL 1

Expert Comment

by:vahan
ID: 6482160
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
0
 

Author Comment

by:weversbv
ID: 6482182
The back slash did not work!!
0
 
LVL 1

Expert Comment

by:vahan
ID: 6482196
you mean browser doesn't accept the cookie?
0
 

Author Comment

by:weversbv
ID: 6482238
What is the use of path and what should be entered at dir??
0
 

Author Comment

by:weversbv
ID: 6482259
I does accept cookies but I want to change the expiration date of the cookie! It can be set onces but not be changed????
0
 
LVL 1

Expert Comment

by:vahan
ID: 6482262
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/
0
 
LVL 1

Accepted Solution

by:
vahan earned 100 total points
ID: 6482267
If you want to change the expiration date, the best choice is to first delete the cookie, by setting it's value to '' (empty)
and then reset it from the scratch with the new exp. date.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Extract multiple value with delimiters from a string 4 168
HTTP Error 502.2 - Bad Gateway 3 204
perl script 4 97
Regular Expression question to filter with negation. 6 89
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now