Hi Roy
$cookie = $q->cookie(-name=>'ID', -value=>"$ID", -expires =>
"-1d", -path=>'/');
I think if you set the expires value to "-1d" you are telling the cookie it has
expired. I would guess that if the cookie was not already set the browserO would
not bother to set one just to expire it. Try "+1d" assuming that this isn't a
typo ;-)
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;
Hang on I'm just digging out my source code ...
OK, here's my sub which authenticates a user and sets a cookie (user
authentication is just here for testing):
sub process_login
{
my $self = shift;
my $query = $self->query(); # Get the Query object
my $dbh = $self->param('dbh'); # Get the db handle (Connect is
done in setup() )
my $new_url = $query->url(-full=>1) . "?rm=show_page"; # Get our URL for
redirect
my ($uname, $fullname, $email, $password) = $dbh->selectrow_array("SELECT
username, fullname, email, password FROM users WHERE username=?;", undef,
$query->param('uname') );
# This is a simple check for testing. Obviously we need to add encrypted
password checks!
if ( ! $uname ){
$self->param('login_message', 'Invalid login');
return $self->show_page();
} else {
# Set cookie
my %cookie_values = (login => $uname,
email => $email,
name => $fullname
);
my $cookie = new CGI::Cookie(-name => 'techweb',
-value =>
\%cookie_values,
-expires =>
'+1h',
);
$self->header_type('redirect');
$self->header_props( -cookie => $cookie,
-url => $new_url
);
}
}
This sub is a run mode of my application and is called when the submit button on
my login form is pressed. AFAIK you can set scalar data in the cookie by using
-value => 'My scalar value' insted of the hash reference.
If you set hash data remember to retrieve it as a hash and not a scalar as this
is what was causing my original problem :-)
Hope this helps.
Best Regards
Paul
*******************************************************************************
Important.
Confidentiality: This communication is intended for the above-named person and
may be confidential and/or legally privileged. Any opinions expressed in this
communication are not necessarily those of the company. If it has come to you
in error you must take no action based on it, nor must you copy or show it to
anyone; please delete/destroy and inform the sender immediately.
Monitoring/Viruses
Orange may monitor all incoming and outgoing emails in line with current
legislation. Although we have taken steps to ensure that this email and
attachments are free from any virus, we advise that in keeping with good
computing practice the recipient should ensure they are actually virus free.
Orange PCS Limited is a subsidiary of Orange SA and is registered in England No
2178917, with its address at St James Court, Great Park Road, Almondsbury Park,
Bradley Stoke, Bristol BS32 4QJ.
*******************************************************************************
---------------------------------------------------------------------
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.