[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cgiapp] [cookies] Having problems getting info out of my cookie


>
> Hi Paul --
>
> > BTW - I'm not sure if there's any bearing but I set the cookie in
> > one run mode
> > and then do "return $self->run_mode_2()" to switch to the run
> > mode which checks
> > the cookie. The only thing I can think of is that $self->query()
> > is not updated
> > when I switch run modes this way ?
>
>
> That is probably the problem.  If you're calling another run-mode directly
> (as opposed to the run-mode being called via an HTTP request) the
> cookie you
> created has not yet been sent to the web browser.  That won't happen until
> run_mode_2() is done.
>
> There are a couple solutions I can think of.  First, you can
> internally pass
> that data to run_mode_2() when you call it.  Second, you could use a
> redirect to get to run_mode_2() instead of a direct call:
>
> 	sub run_mode_1 {
> 		my $self = shift;
> 		my $q = $self->query();
>
> 		my %cookie_values = (
> 			login   => $uname,
> 			email   => $email,
> 			name    => $fullname
> 		);
>
> 		my $cookie = new CGI::Cookie(
> 			-name    =>  'techweb',
> 			-value   =>  \%cookie_values,
> 			-expires =>  '+1h',
> 		);
>
> 		# Set up redirect, set cookie
> 		my $new_url = $q->url(-full=>1) . '?rm=run_mode_2';
> 		$self->header_type('redirect');
> 		$self->header_props(
> 			-cookie => $cookie,
> 			-url    => $new_url
> 		);
>
> 		my $output = "Redirect $new_url";
> 		return $output;
> 	}
>
>
> This will set your cookie and send the user back to run_mode_2 via HTTP
> request.  When they get to run_mode_2 they will have the cookie you need.
>
>
> TTYL,
>
> -Jesse-
>
>
> --
>
>   Jesse Erlbaum
>   The Erlbaum Group
>   suppressed
>   Phone: 212-684-6161
>   Fax: 212-684-6226


I tried your code from above to set the cookie and redirect to a different
run-mode via HTTP and have ran into some problems. Any idea why the cookie
isn't set? I am testing the following code on WIN2K and IIS:

		$cookie = $q->cookie(-name=>'ID', -value=>"$ID", -expires =>
"-1d", -path=>'/');

		my $new_url = $q->url(-full=>1) . '?action=client_main';
		$self->header_type('redirect');
		$self->header_props(-cookie => $cookie, -url=> $new_url);
		my $output = "Redirect $new_url";
		return $output;


Thanks.



Roy Rubin
Irubin Consulting - Internet Solutions
suppressed
Phone (310) 402-0120
Toll-Free (888) 9-IRUBIN
http://www.irubin.com/





---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.