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 2708 eWish 971
Recognized Expert Contributor
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
numberwhun 3,509
Recognized Expert Moderator Specialist
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
numberwhun 3,509
Recognized Expert Moderator Specialist
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
numberwhun 3,509
Recognized Expert Moderator Specialist
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 concept of one particular part of the
"application" (as it were) - session tracking. Perl itself is handling
user authentication (since I've no idea how Perl could "ask" the server
who just authenticated to htaccess), so the login script will have an...
|
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 new session is created. The original and
new session id don't match.
Any help would be appreciated!
|
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 problem is: how could a python CGI program understand several
requests are in the same session? Definately, request from different IP
would be easy to identified to be in different sessions, but request
from the same IP would not.
Anyone has any...
|
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 python.
It's free at http://pnk.com and it is a web timesheet for project
accounting
|
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 in my page it doesn't work..I know i am commiting errors but i cant found exactly what is that..can somebody help me out to rectify this problem...
#!/usr/bin/perl
print"content-type:text/html\n\n";
use CGI::Session;
$session = new...
|
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 qw/:standard/;
use LWP::UserAgent;
use HTTP::Request qw(GET POST);
use HTTP::Headers;
|
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 action.
in all the CGI files including main.cgi I am writing this code before start_html to manage the session:
---------------------------------------
my $cgi = CGI->new;
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |