hey guys,
i'm not sure if u guys have place this problem before
i did an expiration of my CGI session for 1 min
and i got the code below to detect -
if($session->is_expired)
-
{
-
print $cgi->header(-cache_control=>"no-cache, no-store, must-revalidate");
-
print "<p>Your has session expired. Please login again.<p></br>";
-
print "<a href='http://localhost//cgi-bin//mml%20log//login.pl'>Login</a>";
-
}
-
elsif ($session->is_empty)
-
{
-
-
print $cgi->header(-cache_control=>"no-cache, no-store, must-revalidate");
-
print "You have not logged in";
-
}
-
the problem is i know when the session expires, it deletes the session off
now when it expires instead of printing "your session expired"
it keeps printing you have not logged in
so i'm wondering if there's anything wrong with the is_expired function
7 2685
is_expired()
Tests whether session initialized using load() is to be expired. This method works only on sessions initialized with load():
Are you using this function correclty?
--Kevin
Did you initialize the session using the load() function? If not, then using the is_expired() function is no use as it only works for sessions initialized with load();.
Regards,
Jeff
yup i did
ok let me show u my logi script
ignore the ##username## and ##password## portion, i need to mask it off
so this is my log in page -
#!/perl/bin/perl
-
-
use strict;
-
use DBI();
-
use CGI;
-
use CGI::Session(' ip_match ');
-
use Digest::SHA1 qw(sha1);
-
-
my ($dbh, $sth, $name1, $name2, $session);
-
-
my $cgi = new CGI;
-
-
my $username = $cgi->param('username');
-
my $password = $cgi->param('password');
-
-
if($username ne '')
-
{
-
$dbh = DBI->connect("DBI:mysql:database=authentication;host=localhost","##username##","##password##",
-
{RaiseError => 1});
-
-
$sth = $dbh ->prepare("SELECT * FROM `example` WHERE Username='$username' AND Password=SHA1('$password')");
-
$sth->execute();
-
while (my $ref =$sth->fetchrow_hashref()) {
-
$name1 = $ref->{'Username'}, $name2 = $ref->{'Password'};}
-
-
-
-
if ($username eq $name1 && ($username))
-
{
-
$session = new CGI::Session();
-
print $session->header(-location=> "http://localhost//cgi-bin//mml%20log//element_select.pl");
-
}
-
else
-
{
-
print
-
$cgi->header,
-
$cgi->start_html(-title=>'StarHub Login');
-
-
print <<HTML;
-
<FORM METHOD="GET">
-
<div style="height100%; width100%; z-index:-1; position:absolute; top:0px; bottom:0px">
-
<IMG SRC="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\
-
htdocs\\starhub1024by768.jpg" ALT="starhub">
-
</div>
-
<div style="position:absolute; top:223px">
-
<p>You have Entered an Incorrect password or username</p>
-
<p>Please Log in below:</p>
-
<p>Username: <INPUT TYPE=TEXT NAME="username"></p>
-
<p>Password: <INPUT TYPE=PASSWORD NAME="password"></p></br>
-
<INPUT TYPE=SUBMIT name=QUERY2 value="Log In">
-
<a href="http://localhost//cgi-bin//mml%20log//passwordchange.pl">Forget your Password?</a>
-
</div>
-
</FORM>
-
HTML
-
-
print $cgi->end_html();
-
-
}
-
$dbh->disconnect();
-
-
}
-
elsif($cgi->param('action') eq 'logout')
-
{
-
$session = CGI::Session->load() or die CGI::Session->errstr;
-
$session->delete();
-
print $session->header(-location=>"http://localhost//cgi-bin//mml%20log//login.pl");
-
}
-
else
-
{
-
-
print
-
$cgi->header,
-
$cgi->start_html(-title=>'StarHub Login');
-
-
print <<HTML;
-
<FORM METHOD="GET">
-
<div style="height100%; width100%; z-index:-1; position:absolute; top:0px; bottom:0px">
-
<IMG SRC="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\
-
htdocs\\starhub1024by768.jpg" ALT="starhub">
-
</div>
-
<div style="position:absolute; top:223px">
-
<p>Please Log in below:</p>
-
<p>Username: <INPUT TYPE=TEXT NAME="username"></p>
-
<p>Password: <INPUT TYPE=PASSWORD NAME="password"></p></br>
-
<INPUT TYPE=SUBMIT name=QUERY2 value="Log In">
-
</div>
-
</FORM>
-
HTML
-
-
print $cgi->end_html();
-
}
-
if login successful
i direct it to this script -
#!/perl/bin/perl
-
-
use strict;
-
use DBI();
-
use CGI;
-
use CGI::Session(' ip_match ');
-
-
-
my $session;
-
-
my $cgi = new CGI;
-
$session = CGI::Session->load();
-
-
my $mmloption = $cgi->param('mmloption');
-
-
-
if($session->is_expired)
-
{
-
print $cgi->header(-cache_control=>"no-cache, no-store, must-revalidate");
-
print "<p>Your has session expired. Please login again.<p></br>";
-
print "<a href='http://localhost//cgi-bin//mml%20log//login.pl'>Login</a>";
-
}
-
elsif ($session->is_empty)
-
{
-
-
print $cgi->header(-cache_control=>"no-cache, no-store, must-revalidate");
-
print "You have not logged in";
-
}
-
else
-
{
-
-
-
if ($mmloption eq "1")
-
{
-
print $cgi->header(-type=>"text/html",-location=>"http://localhost//cgi-bin//mml%20log//1//optionA.pl");
-
}
-
elsif ($mmloption eq "12")
-
{
-
-
print $cgi->header(-type=>"text/html",-location=>"http://localhost//cgi-bin//mml%20log//12//optionA.pl");
-
}
-
elsif ($mmloption eq "123")
-
{
-
print $cgi->header(-type=>"text/html",-location=>"http://localhost//cgi-bin//mml%20log//123//optionA.pl");
-
}
-
-
elsif ($mmloption eq "1234")
-
{
-
print $cgi->header(-type=>"text/html",-location=>"http://localhost//cgi-bin//mml%20log//1234//optionA.pl");
-
}
-
else
-
{
-
-
-
-
print
-
$cgi->header,
-
$cgi->start_html(-title=>'Elements Selection');
-
-
print <<HTML;
-
-
<FORM METHOD="GET">
-
<div style="height100%; width100%; z-index:-1; position:absolute; top:0px; bottom:0px">
-
<IMG SRC="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\
-
htdocs\\starhub1024by768.jpg" ALT="starhub">
-
</div>
-
<div style="position:absolute; top:223px">
-
<p>Please Select the elements below:</p>
-
<INPUT TYPE=RADIO NAME="mmloption" VALUE="12">12<BR></br>
-
<INPUT TYPE=RADIO NAME="mmloption" VALUE="1">1<BR></br>
-
-
<input type=submit name=Query3 value=Submit>
-
<a href='http://localhost//cgi-bin//mml%20log//login.pl?action=logout'>Logout</a>
-
</div>
-
-
HTML
-
-
print $cgi->end_html();
-
}
-
}
-
hopefully i did it correctly
In your original post, you said you set the expiration to 1 minute. I looked through what you posted and I don't see it. I don't see where you used the expire() function to set the 1 minute time-out.
Regards,
Jeff
opps sorry -
#!/perl/bin/perl
-
-
use strict;
-
use DBI();
-
use CGI;
-
use CGI::Session(' ip_match ');
-
use Digest::SHA1 qw(sha1);
-
-
my ($dbh, $sth, $name1, $name2, $session);
-
-
my $cgi = new CGI;
-
-
my $username = $cgi->param('username');
-
my $password = $cgi->param('password');
-
-
if($username ne '')
-
{
-
$dbh = DBI->connect("DBI:mysql:database=authentication;host=localhost","##username##","##password##",
-
{RaiseError => 1});
-
-
$sth = $dbh ->prepare("SELECT * FROM `example` WHERE Username='$username' AND Password=SHA1('$password')");
-
$sth->execute();
-
while (my $ref =$sth->fetchrow_hashref()) {
-
$name1 = $ref->{'Username'}, $name2 = $ref->{'Password'};}
-
-
-
-
if ($username eq $name1 && ($username))
-
{
-
$session = new CGI::Session();
-
$session->expire("1m");
-
print $session->header(-location=> "http://localhost//cgi-bin//mml%20log//element_select.pl");
-
}
-
else
-
{
-
print
-
$cgi->header,
-
$cgi->start_html(-title=>'StarHub Login');
-
-
print <<HTML;
-
<FORM METHOD="GET">
-
<div style="height100%; width100%; z-index:-1; position:absolute; top:0px; bottom:0px">
-
<IMG SRC="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\
-
htdocs\\starhub1024by768.jpg" ALT="starhub">
-
</div>
-
<div style="position:absolute; top:223px">
-
<p>You have Entered an Incorrect password or username</p>
-
<p>Please Log in below:</p>
-
<p>Username: <INPUT TYPE=TEXT NAME="username"></p>
-
<p>Password: <INPUT TYPE=PASSWORD NAME="password"></p></br>
-
<INPUT TYPE=SUBMIT name=QUERY2 value="Log In">
-
<a href="http://localhost//cgi-bin//mml%20log//passwordchange.pl">Forget your Password?</a>
-
</div>
-
</FORM>
-
HTML
-
-
print $cgi->end_html();
-
-
}
-
$dbh->disconnect();
-
-
}
-
elsif($cgi->param('action') eq 'logout')
-
{
-
$session = CGI::Session->load() or die CGI::Session->errstr;
-
$session->delete();
-
print $session->header(-location=>"http://localhost//cgi-bin//mml%20log//login.pl");
-
}
-
else
-
{
-
-
print
-
$cgi->header,
-
$cgi->start_html(-title=>'StarHub Login');
-
-
print <<HTML;
-
<FORM METHOD="GET">
-
<div style="height100%; width100%; z-index:-1; position:absolute; top:0px; bottom:0px">
-
<IMG SRC="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\
-
htdocs\\starhub1024by768.jpg" ALT="starhub">
-
</div>
-
<div style="position:absolute; top:223px">
-
<p>Please Log in below:</p>
-
<p>Username: <INPUT TYPE=TEXT NAME="username"></p>
-
<p>Password: <INPUT TYPE=PASSWORD NAME="password"></p></br>
-
<INPUT TYPE=SUBMIT name=QUERY2 value="Log In">
-
</div>
-
</FORM>
-
HTML
-
-
print $cgi->end_html();
-
}
-
-
sorry i added it in
i tried with that but it still didn;t work
Unfortunately, I don't know why its not working then. The use would seem correct, but I just don't know. Wish I could help more, sorry.
Regards,
Jeff
hm...all i know is if a session expires
the session is deleted and becomes empty
perhaps that;s why it always detect it is an empty session
i've read some issues on this, apparently it's said to be a bug in the module
but no proven evidence yet
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Frauzel |
last post by:
I'm writing a rough draft of a suite of small Perl apps that will,
combined, serve as a web site's user sign-up, login, management, and
customized content engine.
I'm having trouble with the...
|
by: David Staschover |
last post by:
I'm trying to set up sessions in perl.
The session is initialized fine in session1.cgi
In session2.cgi, the correct session id is returned from the cookie, but
when I initialize the session, a...
|
by: Sullivan WxPyQtKinter |
last post by:
Python disappointly failed to provide a convinient cgi session
management module. Not willing to use external modules, I would like to
implement a simplest Session object on my own.
The basic...
|
by: ccdetail |
last post by:
http://www.tiobe.com/index.htm?tiobe_index
Python is the 7th most commonly used language, up from 8th.
The only one gaining ground besides VB in the top 10.
We're glad, our app is written in...
|
by: rajiv07 |
last post by:
use CGI;
use DBI;
use CGI::Session;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my $c = new CGI::Cookie;
|
by: Lastknight |
last post by:
hi all
I am trying to build a user authentication page for my project..i am getting message im the output as u r sessiion id is...... and it will expires on so....so ..time but when iam using that...
|
by: rajiv07 |
last post by:
I have some problem in session loading
use CGI;
use CGI::Session;
use CGI::Cookie;
my $session = "" ;
my $sid = "" ;
|
by: rajiv07 |
last post by:
Hi to all
I have a script to get geo IP which is successfully running on Linux server.but when i run this script on windows server it gives some header error
#!C:/Perl/bin/perl.exe
use CGI...
|
by: d0353101 |
last post by:
I am having login.cgi. user enter id and password. if ok it redirects to main.cgi with user_id as main_page.cgi?user_id=$user_id.
main.cgi is having left menu and right part is for doing some...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |