You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Yann Ramin <at...@atrustrivalie.eu.org> on 2000/07/19 06:02:25 UTC
Redirecting Users
Hi.
I'm trying to redirect users via. a Location header (internal redirect
is not ideal - I need the browser to send the cookie to the page). The
problem is specifying the header in a header_out doesn't cause it to be
sent. This is my current implementation code:
sub do_login {
my ($self) = @_;
my $uinfo = Nett::UserInfo->new;
my $user = $self->{AR}->param('uname');
my $pass = $self->{AR}->param('passwd');
my $return = $uinfo->auth($user, $pass);
if ($return == 1) {
$self->show_login_page("The user id/password was not
correct.");
exit;
}
<get some data>
my $sess = sha1_hex($seed);
my $c = Apache::Cookie->new($self->{R},
-name => "NettSessionCookie",
-value => $sess,
-path => ".montereyhigh.com",
-expires => "+1d",
-path => "/"
);
$c->bake;
<some db stuff>
$self->{R}->no_cache(1);
$self->{R}->header_out("Location", "/nettexec/welcome");
$self->{R}->send_http_header;
print "redir";
#$self->{R}->internal_redirect("/nettexec/welcome");
}
The cookie gets set just fine, but a Location is never sent (Expire is
though)
--
--------------------------------------------------------------------
Yann Ramin atrus@atrustrivalie.eu.org
Atrus Trivalie Productions www.redshift.com/~yramin
Monterey High IT www.montereyhigh.com
ICQ 46805627
AIM oddatrus
Marina, CA
IRM Developer Network Toaster Developer
SNTS Developer * Developer
"All cats die. Socrates is dead. Therefore Socrates is a cat."
- The Logician
--------------------------------------------------------------------
Re: Redirecting Users
Posted by darren chamberlain <da...@boston.com>.
Yann Ramin (atrus@atrustrivalie.eu.org) said something to this effect:
> Hi.
>
>
> I'm trying to redirect users via. a Location header (internal redirect
> is not ideal - I need the browser to send the cookie to the page). The
> problem is specifying the header in a header_out doesn't cause it to be
> sent. This is my current implementation code:
Yann,
Check out http://perl.apache.org/guide/snippets/#Sending_Cookies_in_REDIRECT_Resp,
which should answer your question. It looks like all you need to do is return
REDIRECT in addition to what you're already doing.
Also, http://perl.apache.org/guide/snippets/#Reading_POST_Data_then_Redirect
might help, as far as REDIRECTs go.
(darren)
--
Blore's Razor:
Given a choice between two theories, take the one which is funnier.