Solved

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

Posted on 1998-08-26
3
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

691 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