Gossamer Forum
Home : General : Perl Programming :

Problem with PDF file loading after Login

Quote Reply
Problem with PDF file loading after Login
Hi,

I use a script that requires everyone to login in prior to downloading any product information (PDF files) The script works fine in NS, however in IE it does not work on logging in.
The following is done on logging in:
- setting of two cookies (username, password)
- load the PDF file using the following code:

Code:
print "Location: http://www.my-site.com/eng/$in{'dname'}/pdf/$in{'fname'}\n\n";

Though Acrobat Reader is started, only a white page is shown in IE.

If further links to PDF files are clicked, the same code is used to open them, yet no cookies are set.
In these cases the script works fine.

So, I suppose that the setting of the cookies might be the problem here.

The script uses a very old cookie library from worldwidemart.com (last modified 12/23/96).

Does anyone have a solution, so that the first PDF file is loaded correctly as well?
Quote Reply
Re: [anhja] Problem with PDF file loading after Login In reply to
If you are setting cookies you can't then do a redirect as a redirect requires that no header is printed first.

Last edited by:

Paul: Aug 28, 2002, 6:38 AM
Quote Reply
Re: [Paul] Problem with PDF file loading after Login In reply to
Thanks for the quick reply.
I tried the line, but got the following error?

Quote:
Software error:
Can't call method "header" on an undefined value

Is there something I did wrong?
(I inserted the code before the print "Location:..." instruction in the script.)
Quote Reply
Re: [anhja] Problem with PDF file loading after Login In reply to
That was just an OO example using a cgi object, you needed to call:

my $IN = new CGI;

....first. Although my code was wrong which is why I removed it.

Last edited by:

Paul: Aug 28, 2002, 8:06 AM
Quote Reply
Re: [Paul] Problem with PDF file loading after Login In reply to
Using CGI objects did not work. So I have been checking various other ways.
Finally I found the following solution. Smile

Instead of using
Code:
print "Location: ...";

I have entered the following lines after setting the cookies

Code:
print "Content-type: text/html\n\n";
print qq~
<META HTTP-EQUIV="refresh" content="0; url= http://www.mysite.com/dir/pdf/$in{'pagename'}">
~;

This works fine (tested on IE 5.0/6.0, NS 4.7/7.0).
Quote Reply
Re: [anhja] Problem with PDF file loading after Login In reply to
If you've already set a header (done when setting cookie) then printing another should be printing:

Content-type: text/html\n\n

...into your page. When you set a cookie you don't need to print a header.

Last edited by:

Paul: Sep 17, 2002, 2:01 AM