Solved

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

Posted on 1998-08-26
3
135 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
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 …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
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 …

758 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

17 Experts available now in Live!

Get 1:1 Help Now