Solved

Setting a cookie from a CGI script (IIS 4.0, NT 4.0)

Posted on 1998-08-26
3
141 Views
Last Modified: 2013-12-25
OS: Win NT 4.0
WS: IIS 4.0

I have a simple CGI script that is supposed to set a cookie and then do a redirect to an image graphic url. The redirect works but the cooie does not get set...

I have tried the following:

1. print "Set-Cookie: CNAME=CVALUE; expires=Mon, 01-JAN-2029 23:59:59 GMT \nLocation: http://www.blah.com/image.gif\n\n";

2. print "Location: http://www.blah.com/image.gif \nSet-Cookie: CNAME=CVALUE; expires=Mon, 01-JAN-2029 23:59:59 GMT \n\n";

3. Just doing the print Location and then using a javascript to print a document.cookie setting.

None of these seem to work as far as having the cookie get set, though the edirect does work. Can anyone help?

Thanks,
Andy
         
0
Comment
Question by:icculus
  • 2
3 Comments
 
LVL 1

Author Comment

by:icculus
ID: 1828313
Edited text of question
0
 
LVL 4

Accepted Solution

by:
mitek earned 50 total points
ID: 1828314
One way to do that would be printing out a page that will contain an http-equiv refresh command:

$redirect_url = "http://www.site.com/abc.asp";
print qq(
Set-Cookie: CNAME=CVALUE; expires=Mon, 01-JAN-2029 23:59:59 GMT \n
Content-Type: text/html\n\n
<HTML>
<HEAD>
<META HTTP-EQUIV="refresh" CONTENT="0; URL=$redirect_url">
</HEAD>
<BODY></BODY>
</HTML>
);

The main point is, this will set the cookie AND immediately redirect to wherever is necessary.
This approach is used in many websites we developed.

0
 
LVL 1

Author Comment

by:icculus
ID: 1828315
Unfortunately this is not working... While the code does set the cookie, the image then appears broken. I did check to make sure the image url was valid and indeed it is...

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

861 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

25 Experts available now in Live!

Get 1:1 Help Now