Cookies and redirection

2001-06-26 Thread Glen Small



All,

I'm having some problem setting a cookie in a logon 
script i have. The code work fine as a CGI, and also under mod)perl, 
however, I want to set a cookie during the login script, and then redirect the 
browser to another page. When I enter the code below into the mod_perl 
script, the browser tries to download login.pl, rather than running it. If 
I print the HTTP header to the screen, it looks fine, but it wont 
run.

This code below works fine under normal CGI. 
Any thoughts ?

use CGI;
use CGI::Cookie;

my $q = new CGI;

...
my $cookie = new CGI::Cookie(-name= 
'testlogger', -value= $UserID, -path = '/');

print $q-redirect(-uri='/perl/home.pl', 
-nph='1', -cookie = $cookie);

...


Re: Cookies and redirection

2001-06-26 Thread darren chamberlain

Glen Small [EMAIL PROTECTED] said something to this effect on 06/26/2001:
 I'm having some problem setting a cookie in a logon script i
 have.  The code work fine as a CGI, and also under mod)perl,
 however, I want to set a cookie during the login script, and
 then redirect the browser to another page.  

http://perl.apache.org/guide/snippets.html#Sending_Cookies_in_REDIRECT_Resp

-- 
The kind of thinking we do sets the stage for the action we are likely
to take. Because of this, a man who refuses to develop his thinking
is likely to act on the impressions made upon him by others.
-- Dr. Claude R. Baker, Coin In The Air



Re: Cookies and redirection

2000-05-09 Thread Wim Kerkhoff


On 09-May-2000 Perrin Harkins wrote:
 Bill Desjardins wrote:
 I checked the archives and the guide to no avail, so here goes. I am
 having trouble setting a cookie in the header and then doing a
 redirect. The cookies are working fine every where, but if I add a cookie
 to $r-headers_out-add(), set a location via $r-headers_out(Location =
 'newrui') and return REDIRECT, I get no cookies being set. is this a bug,
 feature, or a feature of the wonderful world of incompatible browsers?
 
 This is a known problem with certain browsers.  The cookie will get set,
 but will not get returned on this first redirect.  You could try putting
 the cookie data in a query string and looking for it there when it isn't
 in the cookie.
 
 - Perrin

Here's how I got it work to flawlessly (probably not the 'correct' way of doing
it, though :)

$r-send_cgi_header(EOF);
Set-cookie: admin_id=0; path=/
Set-cookie: admin_key=0; path=/
Location: /


EOF
return DONE;



Regards,

Wim Kerkhoff, Software Engineer
NetMaster Networking Solutions
[EMAIL PROTECTED]



Re: Cookies and redirection

2000-05-09 Thread Alex Menendez

not completely sure about real mod_perl. However, the following works
great using Apache::Registry and CGI:

print $query-header(-cookie=[$id_cookie,$crypt_cookie],
 
-Location=$query-param("redirect").'?name='.@$ref[1].'last_login='.@$ref[3].'site_id='.$query-
param('site_id'));

I think Apache::Request will work just in same manner.

-amen

On Tue, 9 May 2000, Robin Berjon wrote:

 At 00:13 09/05/2000 -0700, Perrin Harkins wrote:
 Bill Desjardins wrote:
  I checked the archives and the guide to no avail, so here goes. I am
  having trouble setting a cookie in the header and then doing a
  redirect. The cookies are working fine every where, but if I add a cookie
  to $r-headers_out-add(), set a location via $r-headers_out(Location =
  'newrui') and return REDIRECT, I get no cookies being set. is this a bug,
  feature, or a feature of the wonderful world of incompatible browsers?
 
 This is a known problem with certain browsers.  The cookie will get set,
 but will not get returned on this first redirect.  You could try putting
 the cookie data in a query string and looking for it there when it isn't
 in the cookie.
 
 Isn't there a work-around consisting of making 100% sure the cookie is sent
 before the Location header ?
 
 
 
 .Robin
 All paid jobs absorb and degrade the mind. -- Aristotle
 




Re: Cookies and redirection

2000-05-09 Thread Robin Berjon

At 08:53 09/05/2000 -0700, Perrin Harkins wrote:
On Tue, 9 May 2000, Robin Berjon wrote:
 Isn't there a work-around consisting of making 100% sure the cookie is sent
 before the Location header ?

Not with MSIE.  At least it didn't work for me.

Works here for me with msie 4 and 5.1 on win98.



.Robin
Does the name Pavlov ring a bell?




Re: Cookies and redirection

2000-05-09 Thread Autarch

On Tue, 9 May 2000, Alex Menendez wrote:

 not completely sure about real mod_perl. However, the following works
 great using Apache::Registry and CGI:
 
 print $query-header(-cookie=[$id_cookie,$crypt_cookie],
  
-Location=$query-param("redirect").'?name='.@$ref[1].'last_login='.@$ref[3].'site_id='.$query-
 param('site_id'));
 
 I think Apache::Request will work just in same manner.

First, why the @$ref[1]?  YOu're doing a slice when you really want
$ref-[1].  Anway, Apache::Request does not have any output methods like
CGI so this won't work.

Try checking out Apache::Cookie for the cookie part.  For the redirect you
can do:

$r-header_out( Location = $location );

and then make sure that you send a REDIRECT status to the browser. (Return
REDIRECT from your module).

-dave

/*==
www.urth.org
We await the New Sun
==*/




Re: Cookies and redirection

2000-05-04 Thread Doug MacEachern

On Tue, 2 May 2000, Bill Desjardins wrote:

 Hi all,
 
 I checked the archives and the guide to no avail, so here goes. I am
 having trouble setting a cookie in the header and then doing a
 redirect. The cookies are working fine every where, but if I add a cookie
 to $r-headers_out-add(), set a location via $r-headers_out(Location =
 'newrui') and return REDIRECT, I get no cookies being set. is this a bug,
 feature, or a feature of the wonderful world of incompatible browsers?

try $r-err_headers_out-add instead.