Hi seniors.
I have testing the CGI::Session::Auth , however i found every time, i refresh the page
the script create a new cookie after i logined (authentication is ok).
the problem seems that script is not reading existing cookie properly so treat me as an
new visit and create a new cookie every time.
I wonder if any one could point me the problem?
#!/usr/bin/perl
# this is an test
use CGI;
use CGI::Session;
use CGI::Session::Auth::DBI;
# CGI object for headers, cookies, etc.
my $cgi = new CGI;
# CGI::Session object for session handling
my $session = new CGI::Session(undef, $cgi, {Directory=>'i:/tmp'});
#my $session = new CGI::Session(undef, $self->query, {Directory=>'/tmp'});
# CGI::Session::Auth object for authentication
my $auth = new CGI::Session::Auth::DBI({
CGI => $cgi,
Session => $session,
DSN => "dbi:mysql:host=localhost;database=testdb",
DBUser => "DBUser", ########
DBPasswd => "DBPasswd", ########
#DoIPAuth => 1
});
$auth->authenticate();
# check if visitor has already logged in
if ($auth->loggedIn) {
&showSecretPage;
}
else {
&showLoginPage;
}
I have testing the CGI::Session::Auth , however i found every time, i refresh the page
the script create a new cookie after i logined (authentication is ok).
the problem seems that script is not reading existing cookie properly so treat me as an
new visit and create a new cookie every time.
I wonder if any one could point me the problem?
#!/usr/bin/perl
# this is an test
use CGI;
use CGI::Session;
use CGI::Session::Auth::DBI;
# CGI object for headers, cookies, etc.
my $cgi = new CGI;
# CGI::Session object for session handling
my $session = new CGI::Session(undef, $cgi, {Directory=>'i:/tmp'});
#my $session = new CGI::Session(undef, $self->query, {Directory=>'/tmp'});
# CGI::Session::Auth object for authentication
my $auth = new CGI::Session::Auth::DBI({
CGI => $cgi,
Session => $session,
DSN => "dbi:mysql:host=localhost;database=testdb",
DBUser => "DBUser", ########
DBPasswd => "DBPasswd", ########
#DoIPAuth => 1
});
$auth->authenticate();
# check if visitor has already logged in
if ($auth->loggedIn) {
&showSecretPage;
}
else {
&showLoginPage;
}