Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP: Cookies and things...

Status
Not open for further replies.

pmachin

Programmer
Feb 20, 2004
5
US
Greetings everyone! I'm a newbie to Perl, hopefully some of you more experienced programmers can help me out.

I have 3 questions that are driving me nuts:

1:
I have the following code creating a cookie:

use CGI;
$query = new CGI;
my $cookie = $query->cookie(-name=>'cookie', -value=>'hello', -domain=>'print $query->header(-cookie=>$cookie);

this scrpt (login.cgi)is in the cgi-bin directory, I forward this script to home.cgi in the same cgi-bin directory and works fine when it accesses the cookie in home.cgi, however, when I put home.cgi one directory above cgi-bin, the cookie is not accessed.

The following is the cookie retrieving code in home.cgi:

#print "Content-type: text/html\n\n";

$query = new CGI;
$cookie = $query->cookie('cookie');

print $query->header();

if ($cookie)
{
#print "Content-type: text/html\n\n";

$query = new CGI;
$cookie = $query->cookie('cookie');

print $query->header();

if ($cookie)
{
print "done";
}
else
{
print "naughty boy!"
#print &quot;#print &quot;<META HTTP-EQUIV=&quot;Refresh&quot; CONTENT=&quot;0;URL=http://myaddressgoeshere.com/cgi-bin/login.cgi&quot;>&quot;;
}

why is 'done' printed if I put the cookie in the same directory, but 'naughty boy' is printed if I put it in another directory? I tried changing the other parameters in cookie creation to make the cookie accessible in the whole domain of my website, but for some reason this is not working!

2:
Another thing, the meta tag that I have commented out, does not work even when the elseif is taken, is there anything wrong with the tag, is global accessing like that alright?

3:
Lastly, I am writting my html files with dreamweaver, however, if I want to read them in again, all this extra code that checks for the cookie and so forth prevents me from seeing anything but the code view in dreamweaver, does perl have any way to redirect to a file within a secure directory. This would solve two problems
1. I won't have to check for cookies at all
2. I would redirect to a complete html file (not mixed with cgi) so that I could edit it with dreamweaver.
If this is not possible, how do you redirect to an unsecure file (without the html meta tag).

Thanks a bunch.
 
Due to the nature of cgi-bin directories and the need for your scripts to access certain system/machine functions on a reasonably secure level, all of your cgi scripts must reside in the cgi-bin directory in order to work properly.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top