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

x
?
Solved

displaying HTML page after cookie set

Posted on 1998-11-20
2
Medium Priority
?
175 Views
Last Modified: 2013-12-25
Here's the scenario that a user would go through when selecting a particular link on the site I'm building:

1.  cgi script that determines whether the user has ever been there before.  If "yes" then #4 below, else #2.
2.  form for first-timers that asks for a couple pieces of info.
3.  cgi script which stores the couple pieces of info in a cookie.
4.  the main page of interest.

My question is how does the script in #3 manage both to write a cookie AND then give the user a complex HTML page back?  I want the HTML page in its own file, i.e., I don't want to just print it out one line at a time from my Perl cgi script.  The last two lines of the script currently look like this...

print "Content-type: text/html\n";
print "Set-Cookie: username=$FORM{'username'} calhost=$FORM{'calhost'};
expires=Thu, 31-Dec-98 12:00:00 PST; path=/projects/blitz\n\n";

I thought of having the next line output a server-side include for the entire HTML file, but the server I'm using (I'm not the webmaster) doesn't seem to be set up for SSIs.

Is there another way?  
0
Comment
Question by:leta
[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 Comments
 
LVL 2

Accepted Solution

by:
chrisbolt earned 400 total points
ID: 1829714
First of all, I think the Set-Cookie header should be printed before the Content-type header but I am not sure... second, for the complex page you have a couple of options:

1: Use this code to open a separate file and print the output:

open(INFOFORM,"/path/to/htmlfile.html");
print <INFOFORM>;
close(INFOFORM);

2: Instead of printing each line out separately, print it like this:

print <<EOHTML;
<HTML>
. (the rest of your page goes here, just remember to escape @ with the backslash. Quotes and everything work okay, and you don't have to print it out line by line)
</HTML>
EOHTML
0
 

Author Comment

by:leta
ID: 1829715
Solution #2 doesn't meet my criterion that my complex HTML
file be allowed to remain a separate file.  But solution #1
is PERFECT!  I'm rather embarrassed that I couldn't think of
this, but I was so sure that there was some cgi thing that I
didn't know about that I wasn't spending much energy on Perl
solutions.  I did try one very similar thing...

      system("cat myhtmlfile");

but the output from system calls evidently doesn't go to the
same place as the output from print statements.  It should have
been a small mental leap from my attempt to yours, but I was
mentally blocked by that point!

THANKS!!!  
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

604 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