RE: [Cgi-session-user] CGI::Session does not seem to be working for me
Brought to you by:
sherzodr
From: Sherzod R. <she...@ha...> - 2005-09-14 19:32:32
|
Vahid, You seriously have to upgrade. The one you're using right now is 4 years, and at least 20 releases old. Get the most recent from http://search.cpan.org/dist/CGI-Session/ . Re-try those two scripts, and let us know. -- Sherzod > -----Original Message----- > From: cgi...@li... > [mailto:cgi...@li...] On > Behalf Of Vahid Hedayati > Sent: Wednesday, September 14, 2005 9:57 AM > To: cgi...@li... > Subject: Re: [Cgi-session-user] CGI::Session does not seem to > be working for me > Importance: High > > > The below test fails it keeps resetting session ID's and counter > remains on 1.. > > > Testing CGI::Session 3.1.4.1 > > > CGISESSID : dbaaf2e4bb0fdc16982906e6c8ff880c > > > Counter: 1 > > > Testing CGI::Session 3.1.4.1 > > > CGISESSID : a1b974c2eef270e24dd42ed4a8803f18 > > > Counter: 1 > > > I also saw another posting so i thought i try out the script > the below > script fails on section 2 > > ok 1 - found session id > not ok 2 - found session data file > # Failed test (./test.pl at line 16) > 1..2 > # Looks like you failed 1 test of 2. > > #!/usr/bin/perl -w > use File::Spec; > use Test::More qw/no_plan/; > > use CGI::Session; > > if (CGI::Session->VERSION >= 4) { > *CGI::Session::DESTROY = sub { > my $s = shift; > $s->flush() or die > "Flush seems to > have failed: ".$s->errstr; > }; > } > > my $dir = File::Spec->catdir('t', 'sessiondata'); > my $id; > my $ses = CGI::Session->new(undef,undef,{Directory=> $dir }); > $id = $ses->id(); > ok($id, "found session id"); > END { ok(-r "$dir/cgisess_".$id, "found session data file"); } > > > > > > > Sherzod Ruzmetov wrote: > > >Vahid > > > >Try the following short script to test. If everything goes > well, you should > >see a persistent session id, and a counter which should > increment each time > >the page is revisited or refreshed (see > >http://author.handalak.com/cgi-bin/session ). If it doesn't, > there really is > >a problem and we'll work on it. > > > >P.S. You would discover this eventually, but you should look into > >CGI::Application and HTML::Template (Or Template Toolkit). > The way you're > >doing things right now (with if/else, and embedded 'HTML'), > you can only go > >so far. > > > > > >#!/usr/bin/perl -w > > > >use strict; > >use CGI; > >use CGI::Carp ('fatalsToBrowser'); > >use CGI::Session; > > > >my $query = CGI->new(); > >my $session = CGI::Session->new(undef, undef, {Directory=>'/tmp'}); > >my $counter = $session->param('counter') || 0; > >$session->param('counter', ++$counter); > > > >my $cookie = $query->cookie(-name=>$session->name, > -value=>$session->id, > >-expires=>"+1h"); > >print $query->header(-cookie=>$cookie), > > $query->start_html("CGI::Session - " . $session->VERSION), > > $query->h1("Testing CGI::Session " . $session->VERSION), > > $query->h2($session->name . " : " . $session->id), > > $query->h3("Counter: $counter"), > > $query->end_html(); > > > >If it works, there's a problem with your code. > > > > > > > > > > > >>-----Original Message----- > >>From: cgi...@li... > >>[mailto:cgi...@li...] On > >>Behalf Of Vahid Hedayati > >>Sent: Monday, September 12, 2005 11:26 AM > >>To: cgi...@li... > >>Subject: [Cgi-session-user] CGI::Session does not seem to be > >>working for me > >>Importance: High > >> > >> > >>CGI::Session version (3) / Perl v.5.8.6 : on FreeBSD 4.7 > >> > >>I have been trying for many hours to get CGI::Session to work: > >> > >>Here is my outcome after many hours of online searching testing: > >> > >>Trying to run a cgi script which authenticates after step 1 > and then > >>runs specfic actions once authenticated.. > >> > >>Here is the web results: > >> > >> > >>_____+++++++ > >>Original Session ID is > >>++++ > >> > >>Welcome vahid you are now logged in > >> > >>Global username = vahid ::: 8d257f413fab17680ea94a176b3d71a6Clik me > >><http://logmgr/cgi-bin/Provision2.cgi?act=vf> > >> > >>__________________Once clicked shows no STORED Session ID > >>and no global > >>username at the bottom has a new SESSION ID: --> > >> > >>___+++++++ > >>Original Session ID is > >>++++ > >>Global username = ::: 6afdaa81cb7c88dc195e1aaab41adf59Clik me > >><http://logmgr/cgi-bin/Provision2.cgi?act=vf> > >> > >> > >>Basically what ever i have tried i end up with new session ids.. > >> > >> > >>here is the code: > >> > >> > >>This is the top of the script: > >> > >> > >> > >>if ($act eq '' ) { > >> $cg = new CGI; > >> $session = new CGI::Session(undef,undef,{Directory=>"/tmp/"}); > >> $cookie = $cg->cookie(CGISESSID => $session->id); > >> print $cg->header( -cookie=>$cookie ); > >> $sid=$session->id; > >> print "Session ID is $sid<br>"; > >> &startup(); > >>} else { > >> $cg = new CGI; > >> $sid=$cg->cookie("CGISESSID"); > >> print "_____$sid+++++++<br>"; > >> $session = new CGI::Session(undef,$sid,{Directory=>"/tmp/"}); > >> print "Original Session ID is $sid<br>"; > >> $sid = $session->id(); > >> print "++++$sid_____<br>"; > >> &$act; > >>} > >> > >>sub startup { > >> > >> $value="logon2.htm"; > >> &do($value); > >>} > >> > >> > >> > >>sub login { > >> $username=$cgi->param(username); > >> $pass=$cgi->param(pass); > >> if (($pass eq '') || ($username eq '' ) ) { > >> print "<hr size=3 width=100%>"; > >> print "Missing Fields please hit back and try again - > >>process halted"; > >> print "<hr size=3 width=100%>"; > >> } else { > >> my $result = $ldap->bind("uid=$username,$base", password=>$pass); > >> if($result->is_error()){ > >> my $errorMessage = $result->error(); > >> print "$errorMessage"; > >> } else { > >> $session->param( "user_name","$username" ); > >> print "<p class=td align=center>Welcome $username you are now > >>logged in</p>"; > >> &vf; > >> # print > >>"<script>\nwindow.location.replace(\"/cgi-bin/$formname?act=vf > >>\");\n</script>"; > >> } > >> } > >>} > >> > >>sub vf { > >> #$gname= cookie($gusername); > >> $gname = $session->param("user_name"); > >> > >> print "Global username = $gname ::: $sid"; > >> print "<a href=/cgi-bin/Provision2.cgi?act=vf>Clik me</a>"; > >>} > >> > >> > >> > >> > >> > >>------------------------------------------------------- > >>SF.Net email is Sponsored by the Better Software Conference & EXPO > >>September 19-22, 2005 * San Francisco, CA * Development > >>Lifecycle Practices > >>Agile & Plan-Driven Development * Managing Projects & Teams * > >>Testing & QA > >>Security * Process Improvement & Measurement * > >>http://www.sqe.com/bsce5sf > >>_______________________________________________ > >>Cgi-session-user mailing list > >>Cgi...@li... > >>https://lists.sourceforge.net/lists/listinfo/cgi-session-user > >> > >> > >> > >> > > > > > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App > Server. Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Cgi-session-user mailing list > Cgi...@li... > https://lists.sourceforge.net/lists/listinfo/cgi-session-user > > |