Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-08-26
3
Medium Priority
?
162 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…
Suggested Courses

618 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