However problem comes when I try to redirect user to the section of the website where user intended to go after writing cookie. So for example if user wants to enter/update his monthly report, when he clicks on that link, system should check for existing cookie and if no cookie is found, write cookie and then redirect to 'enter/update data' section. When I try to re-direct immediately after writing cookie, cookie information is lost!! Here is the code-my $self = shift; my $query = $self->query(); my $redirectTo = $query->param('redirectTo'); ---- ---- $userDetails='<all info that needs to be stored>'; my $expires = '+12M'; my $kpi_cookie = $query->cookie(-name=>'kpi', + -value=>$userDetails, + -expires=>$expires,); $self->header_props(-cookie=>[$kpi_cookie]); my $template = $self->load_tmpl('index.html'); my $lmess = "Successfully logged in"; $template->param(MSG => $lmess); return $template->output;
I am not sure where I am making mistake!!............ ............ my $redirectTo = $query->param('redirectTo'); my $this_url = $query->script_name(); $userDetails='<all info that needs to be stored>'; my $expires = '+12M'; my $kpi_cookie = $query->cookie(-name=>'kpi', + -value=>$userDetails, + -expires=>$expires,); $self->header_props(-cookie=>[$kpi_cookie]); my $redirect_url=$this_url.'?rm='.$redirectTo; $self->header_type('redirect'); $self->header_props(-url => $redirect_url); return;
In reply to Cookie problem by bar10der
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |