cgi-session-user Mailing List for CGI-Session (Page 15)
Brought to you by:
sherzodr
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
(13) |
Apr
(6) |
May
(2) |
Jun
(3) |
Jul
(2) |
Aug
(10) |
Sep
(9) |
Oct
(15) |
Nov
(1) |
Dec
(4) |
2004 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
(1) |
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
(1) |
May
(9) |
Jun
|
Jul
(14) |
Aug
(32) |
Sep
(34) |
Oct
(16) |
Nov
(6) |
Dec
(15) |
2006 |
Jan
(5) |
Feb
(27) |
Mar
(60) |
Apr
(12) |
May
(17) |
Jun
(24) |
Jul
(27) |
Aug
(16) |
Sep
(13) |
Oct
(19) |
Nov
(22) |
Dec
(29) |
2007 |
Jan
(23) |
Feb
(33) |
Mar
(42) |
Apr
(30) |
May
(14) |
Jun
(5) |
Jul
(12) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2008 |
Jan
(6) |
Feb
(9) |
Mar
(48) |
Apr
(20) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
(9) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(11) |
Oct
(2) |
Nov
|
Dec
|
2010 |
Jan
(9) |
Feb
(28) |
Mar
|
Apr
(12) |
May
(13) |
Jun
|
Jul
(3) |
Aug
|
Sep
(1) |
Oct
(3) |
Nov
|
Dec
(9) |
2011 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
2015 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Sergey B. <si...@gm...> - 2006-07-23 13:27:26
|
Hi, Mark. I've run your tests. The results is ok 1 - session starts out undef ok 2 - session is true after getInstance not ok 3 - multiple call to getInstance return the same session ID 1..3 As I see the problem not in CGI::Session and SessionSingleton. Problem is in initizliaing session. After first call session object has internal status = 1, after the second call internal status is changing to 2. Session object with status 2 is normal session object. My SessionSingleton always returns session object with status 1, it never richs status 2. To use CGI::Application::Plugin::Session I have to create separate package, but I wouldn't like it. I just want to use SessionSingleton in simple script (not in package). > Sergey, > > It's frustrating that you haven't followed up on the advice given to > you of writing some tests. Here are some tests I wrote for the case. > Do they pass for you when you run these tests in a file? > > If they do, your problem is elsewhere, or you need to write a new test > to share with us that illustrates your problem. If the tests don't pass, > check that you are using the latest version of CGI::Session. > > Finally, consider using CGI::Application and > CGI::Application::Plugin::Session instead! They are a lightweight, > proven solution to provide a singleton for a CGI::Session object. > > Mark > |
From: Mark S. <ma...@su...> - 2006-07-23 12:49:50
|
Sergey Brutsky wrote: > I've changed my code in agree to your code, it doesn't work. > > I think that problem, probably, in initializing session instance. > It initializes in two steps: creating session instance and then > reinitializing session (reading CGISESSID and creating session file). > It seems that my getInstance() method returns "half-initialized" session > object. > I mean to use condition "defined $session" is not enough. > getInstance() should initialize sesssion, reinitialize and only after > that returns instance. Sergey, It's frustrating that you haven't followed up on the advice given to you of writing some tests. Here are some tests I wrote for the case. Do they pass for you when you run these tests in a file? If they do, your problem is elsewhere, or you need to write a new test to share with us that illustrates your problem. If the tests don't pass, check that you are using the latest version of CGI::Session. Finally, consider using CGI::Application and CGI::Application::Plugin::Session instead! They are a lightweight, proven solution to provide a singleton for a CGI::Session object. Mark -- http://mark.stosberg.com/ #!/usr/bin/perl package SessionSingleton; my $session; sub getInstance { defined $session or $session = CGI::Session->new(); return $session; } use Test::More 'no_plan'; use CGI::Session; my $session1; is($session1,undef, "session starts out undef"); $session1 = SessionSingleton->getInstance; ok($session1, "session is true after getInstance"); my $sid = $session->id; $session2 = SessionSingleton->getInstance; is($sid,$session2->id, "multiple call to getInstance return the same session ID"); |
From: Sergey B. <si...@gm...> - 2006-07-23 11:15:53
|
I've changed my code in agree to your code, it doesn't work. I think that problem, probably, in initializing session instance. It initializes in two steps: creating session instance and then reinitializing session (reading CGISESSID and creating session file). It seems that my getInstance() method returns "half-initialized" session object. I mean to use condition "defined $session" is not enough. getInstance() should initialize sesssion, reinitialize and only after that returns instance. Is any ideas how to change condition (defined $session) to condition which will check if sesion object "full-initialized" ? > On 7/21/06, Sergey Brutsky <si...@gm...> wrote: > >> sub getInstance >> { >> defined $session or $session = CGI::Session->new( undef, undef, { Directory => "/tmp/session" } ); >> return $session; >> > > *snip* > > >> my $session = SessionSingleton->getInstance(); >> > > The definition of getInstance looks to be incorrect. It should look > something more like: > sub getInstance { > defined $session ? $session : ($session = CGI::Session->new( > undef, undef { Directory => "/tmp/session" })) > } > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Cgi-session-user mailing list > Cgi...@li... > https://lists.sourceforge.net/lists/listinfo/cgi-session-user > > |
From: Matt L. <mle...@cp...> - 2006-07-21 16:14:01
|
On 7/21/06, Sergey Brutsky <si...@gm...> wrote: > sub getInstance > { > defined $session or $session = CGI::Session->new( undef, undef, { Directory => "/tmp/session" } ); > return $session; *snip* > my $session = SessionSingleton->getInstance(); The definition of getInstance looks to be incorrect. It should look something more like: sub getInstance { defined $session ? $session : ($session = CGI::Session->new( undef, undef { Directory => "/tmp/session" })) } |
From: Mark S. <ma...@su...> - 2006-07-21 13:22:47
|
Sergey Brutsky wrote: > Hi, mark. I can't write Test::More test. Why not? The module is free, easy to use and well documented. Here's a first test to get you started: use Test::More 'no_plan'; my $session; { ok((not defined $session), "session starts out undefined"); } > The problem is: > If I use this construction --> my $session = CGI::Session->new( undef, > undef, { Directory => "/tmp/sessions" } ); > it works fine. > > But if I use this --> my $session = SessionSingleton->getInstance(); > it doesn't work. It doesn't create session and doesn't store it. > > Why ? I can't say for sure, but it's not clear that's a bug in CGI::Session, either. Why not study the working singleton example code in the module I mentioned below? Clearly it's possible to write one. Mark >> >> >> Sergey, >> >> The subject says that the module is not working correctly, but I'm not >> sure exactly which bug you reporting. Could just share a failing >> Test::More-style test case that clearly illustrates the issue? >> >> As for your singleton package, you may which to model it after >> CGI::Application::Plugin::Session, which does this successfully: >> >> http://search.cpan.org/src/CEESHEK/CGI-Application-Plugin-Session-1.02/lib/CGI/Application/Plugin/Session.pm |
From: Mark S. <ma...@su...> - 2006-07-21 12:24:17
|
Sergey Brutsky wrote: > Hi guys. > I have a very small trouble; > I have 2 files index.pl and SessionSingleton.pm. > > If I use this construction my $session = CGI::Session->new( undef, undef, { Directory => "/tmp/sessions" } ); > it works fine > > But if I use this CGI::Session->new( undef, undef, { Directory => "/tmp/sessions" } ); > it doesn't work, sessions are not created. > > Why ? And what should I correct in SessionSingleton file to made it works properly ? Sergey, The subject says that the module is not working correctly, but I'm not sure exactly which bug you reporting. Could just share a failing Test::More-style test case that clearly illustrates the issue? As for your singleton package, you may which to model it after CGI::Application::Plugin::Session, which does this successfully: http://search.cpan.org/src/CEESHEK/CGI-Application-Plugin-Session-1.02/lib/CGI/Application/Plugin/Session.pm Mark |
From: Sergey B. <si...@gm...> - 2006-07-21 11:37:52
|
Hi guys. I have a very small trouble; I have 2 files index.pl and SessionSingleton.pm. If I use this construction my $session = CGI::Session->new( undef, undef, { Directory => "/tmp/sessions" } ); it works fine But if I use this CGI::Session->new( undef, undef, { Directory => "/tmp/sessions" } ); it doesn't work, sessions are not created. Why ? And what should I correct in SessionSingleton file to made it works properly ? file SessionSingleton.pm ---------------------------------------------------------------------------- package SessionSingleton; use CGI::Session; my $session; sub getInstance { defined $session or $session = CGI::Session->new( undef, undef, { Directory => "/tmp/session" } ); return $session; } 1; ~ ---------------------------------------------------------------------------- file index.pl ---------------------------------------------------------------------------- use SessionSingleton; use CGI; use CGI::Session; my $cgi = CGI->new; my $session = SessionSingleton->getInstance(); #my $session = CGI::Session->new( undef, undef, { Directory => "/tmp/sessions" } ); $cgi->cookie( CGISESSID => $session->id ); print $session->header; print $session->id; exit 0; |
From: Randall H. <ra...@ra...> - 2006-07-17 17:21:50
|
On Mon, Jul 10, 2006 at 12:51:26PM -0400, Mark Stosberg wrote: > As you can see from the snippet you posted, CGI::Session is setting the= =20 > error. >=20 > As documented, this error is available through the errstr() method if=20 > you want to see the error. It's the user's responsibility to check this= =20 > error. Thanks for the reply, Mark. Normally I'd agree with you, but the error is occuring in CGI::Session's flush() method, which is called automatically when the object goes out of scope. So unless I call flush() explicitly, I'll never have an opportunity to check for the error. In practice, it means that I either need to create a destructor, or call flush() then check errstr() at every possible exit point for the code. It seems sub-optimal to me that CGI::Sesion says, in effect, "Trust me to call flush() automatically, but I won't promise it will do anything useful." IMHO if flush() is called automatically it should die of its errors, otherwise it isn't trustworthy. r |
From: Dmitri T. <dti...@vo...> - 2006-07-11 18:50:51
|
Dear Mark, Sherzod, and the List: I would like to know what you think about the following API enhancement: I would like to be able to expire certain parameters based on mtime, not atime. Current 'expire' method only works with access time. Reason: I have a DB-driven web site. In order to improve performance, I store some query results in session variables. But those I'd like to refresh from time to time. To achieve this, I do things like $session->param('abc', $value); $session->param('abc_mtime', time); # And later: if ($session->param('abc_mtime') + $interval < time) { # expired. } I would love to be able to say $session->param('abc', $value); $session->expire_mtime('abc', '2m'); # or something like that and be done with it. Questions: a) what do you think? b) if I implement it, will you accept the patch? c) if the answer to (b) is yes, what kind of method name would you like? Sincerely, - Dmitri. |
From: Matt L. <mle...@cp...> - 2006-07-10 23:35:27
|
The error is produced because the postgresql driver binds the data to the query with the data type (either PG_BYTEA or PG_TEXT). Thus if you specify ColumnType => 'binary' when it's of type text, postgresql's going to wonder wtf we're trying to do since the driver attempts to bind as bytea and then postgresql complain about our warped sense of reality. In other words: a_session is bytea, specify ColumnType => 'binary' a_session is text, omit ColumnType or set ColumnType => 'text' a_session is something else, fix it =) I believe you already know this, but I'm clarifying for the other people who might stumble upon this thread with a similar problem. Anyway, with regard to Mark's suggestion of a PrintError, I think that would be a good idea. Perhaps we could also make it respect an environmental variable for on-the-fly troubleshooting. |
From: Ron S. <ro...@sa...> - 2006-07-10 21:50:55
|
On Mon, 10 Jul 2006 12:51:26 -0400, Mark Stosberg wrote: Hi Mark >> 'flush(): couldn\'t store datastr: store(): serialize to db >> failed ERROR: column "a_session" is of type text but expression >> is of type bytea HINT: You will need to rewrite or cast the >> expression. Is Postgres saying the expression is of type bytea because it contains a= null char? -- Cheers Ron Savage, ro...@sa... on 11/07/2006 http://savage.net.au/index.html Let the record show: Microsoft is not an Australian company |
From: Mark S. <ma...@su...> - 2006-07-10 16:52:28
|
Randall Hansen wrote: > Hi folks ~ > > I've used CGI::Session for a couple years, and not had much trouble > until recently. I did something silly, and the module accepted it > silently, with no error message. > > I was using the wrong column definition for a_session in PostgreSQL, > and the module silently refused to freeze the session. I only figured > out what was going on by changing this, on line 206 of version 4.03: > > defined( $driver->store($self->id, $datastr) ) or > return $self->set_error( "flush(): couldn't store datastr: " . $driver->errstr); > > # changed to this: > > unless( defined( $driver->store($self->id, $datastr) )) { > use Data::Dumper; > print STDERR Dumper[ "flush(): couldn't store datastr: " . $driver->errstr)]; > return $self->set_error( "flush(): couldn't store datastr: " . $driver->errstr); > } > > Then I got this error, telling me what I was doing wrong: > > 'flush(): couldn\'t store datastr: store(): serialize to db failed > ERROR: column "a_session" is of type text but expression is of > type bytea > HINT: You will need to rewrite or cast the expression. > > So it's my fault for defining the table incorrectly, but OTOH it seems > odd that CGI::Session didn't cough up the error. The rest of my app > writes errors just fine when PostgreSQL is unhappy. R, As you can see from the snippet you posted, CGI::Session is setting the error. As documented, this error is available through the errstr() method if you want to see the error. It's the user's responsibility to check this error. I suppose it's possible we could add a feature like DBI has with the {PrintError} attribute, which would cause errors to always be printed to STDERR. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer ma...@su... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . |
From: Randall H. <ra...@ra...> - 2006-07-10 16:34:38
|
Hi folks ~ I've used CGI::Session for a couple years, and not had much trouble until recently. I did something silly, and the module accepted it silently, with no error message. I was using the wrong column definition for a_session in PostgreSQL, and the module silently refused to freeze the session. I only figured out what was going on by changing this, on line 206 of version 4.03: defined( $driver->store($self->id, $datastr) ) or return $self->set_error( "flush(): couldn't store datastr: " . $driver->errstr); # changed to this: unless( defined( $driver->store($self->id, $datastr) )) { use Data::Dumper; print STDERR Dumper[ "flush(): couldn't store datastr: " . $driver->errstr)]; return $self->set_error( "flush(): couldn't store datastr: " . $driver->errstr); } Then I got this error, telling me what I was doing wrong: 'flush(): couldn\'t store datastr: store(): serialize to db failed ERROR: column "a_session" is of type text but expression is of type bytea HINT: You will need to rewrite or cast the expression. So it's my fault for defining the table incorrectly, but OTOH it seems odd that CGI::Session didn't cough up the error. The rest of my app writes errors just fine when PostgreSQL is unhappy. Any ideas? TIA, r |
From: Roopali S. <roo...@gm...> - 2006-07-08 10:44:37
|
Reshtey Millangen Aise Aap Chahenge Jaise At http://www.jaintojain.com <http://www.jaintojain.org/> Ek Rishta Vishwas Ka <http://www.jain2jain.org/ms/> Agar Aap K Ghar Main Ya Parivaar main Koi Shaadi Layek Ho to Aap Uska Biodata <http://www.jain2jain.org/ms/> Hummare Site Per Free Register Kara Sakten Hain <http://www.jaintojain.com/> Jain<http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww%2Ekayasthatokayastha%2Ecom%2F&isImage=0&BlockImage=0> Brides and Grooms E.g.: Jain, Shah, Bansal, Garg, Goyal, Mehta, etc.<http://www.jain2jain.org/ms/> http://www.jaintojain.com <http://www.jain2jain.org/ms/> FREE ONLINE REGISTRATION <http://www.jain2jain.org/ms/> SO <http://www.jaintojain.com/> *Register today* <http://www.jaintojain.org/> |
From: Srinivasa R. <sri...@gm...> - 2006-06-28 13:03:18
|
My name is srinivas, I am using ur CGI::Session module , but i am not able retrieve the stored data in a session in another page, could u please give me the sample program how to do this.I am working under windows 2000 with Active State 5.8.7.813.I installed ur CGI::Session using PPM. It is very urgent for me, i strucked in middle of the project. Thanks & Regards Srinivasa Rao S |
From: Ron S. <ro...@sa...> - 2006-06-21 06:07:12
|
On Wed, 21 Jun 2006 10:19:11 +0530, Srinivasa Rao wrote: Hi Srini Program: -----><8----- #!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Session; # --------------- my($id) = ''; my($q) = CGI -> new(); print "No Session ID passed in: \n"; { # This is program 1. $q -> param(CGI::Session -> name() => $id); my($session) = CGI::Session -> new(); print $session -> id(), '. New?: ', ($session -> is_new() ? 'Yes' : 'No'), ". \n"; $id = $session -> id(); } print "\n"; print "Valid Session ID passed in: \n"; { # This is program 2. $q -> param(CGI::Session -> name() => $id); my($session) = CGI::Session -> new($q); print $session -> id(), '. New?: ', ($session -> is_new() ? 'Yes' : 'No'), ". \n"; $id = $session -> id(); } -----><8----- Output: -----><8----- No Session ID passed in: 7f0e7c80669ef35b203a2001b456727e. New?: Yes. Valid Session ID passed in: 7f0e7c80669ef35b203a2001b456727e. New?: No. -----><8----- Code ripped off (without ado or acknowledgement) from Cees Hek. -- Ron Savage ro...@sa... http://savage.net.au/index.html |
From: Srinivasa R. <sri...@gm...> - 2006-06-21 04:49:16
|
Hi Ron Savage, Thanks For Replaying, in the second page i am getting the Session id and i am passing that session id to the CGI::Session as a parameter , but it is creating new session and i am not able to get the values what i stored in the first page.I am able to print the seesion id in the next page but i am not able maintain the session.Please help me .If u have any doubts please feel free to contact me. Regards Srinivasa Rao S On 6/21/06, cgi...@li... < cgi...@li...> wrote: > > Send Cgi-session-user mailing list submissions to > cgi...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/cgi-session-user > or, via email, send a message with subject or body 'help' to > cgi...@li... > > You can reach the person managing the list at > cgi...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Cgi-session-user digest..." > > > Today's Topics: > > 1. Hi Sir (Srinivasa Rao) > 2. Re: Hi Sir (Ron Savage) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 20 Jun 2006 09:56:45 +0530 > From: "Srinivasa Rao" <sri...@gm...> > Subject: [Cgi-session-user] Hi Sir > To: "cgi...@li..." > <cgi...@li...> > Message-ID: > <ad9...@ma...> > Content-Type: text/plain; charset="iso-8859-1" > > My Name is Srinivas, > I am devloping a CGI application using Perl. I am using CGI::Session > module,here i am facing a problem, i am not able to retrieve the session > values from one page to anther page.Could u please help me out.My program > is > below > > First Page > use CGI::Session; > use CGI qw/:standard/; > $session = new CGI::Session(); > my $CGISESSID = $session->id(); > print header(); > print start_html(); > print '<form id="MainForm" method="Post" width="200px" >'; > $session->param('f_name', 'Sherzod'); > $session->param(-name=>'l_name', -value=>'Ruzmetov'); > my $f_name = $session->param('f_name'); > my $l_name = $session->param(-name=>'l_name'); > print '<input type=button value=FWD onclick="Action()">'; > print '<script language="Javascript">'; > print 'function Action() > { > document.forms(0).action="s.pl?'.$session->name.'='.$CGISESSID.'"; // > Here the Session values are getting stored as querystring > document.forms(0).submit(); > }' ; > print '</script>'; > print end_html(); > > Second Page S.pl > > > > > use CGI qw(:standard); > use CGI::Session; > print header; > print start-html(); > my $name; > my $value; > if (length ($ENV{'QUERY_STRING'}) > 0){ > my $buffer = $ENV{'QUERY_STRING'}; > my @pairs = split(/&/, $buffer); > ($name, $value) = split(/=/, $pairs[0]); > > } > my $session = new CGI::Session( $value); > print $session->name; > print $session->id; > print $session->param('f_name'); > print end-html(); > > > > Regards > > Srinivasa Rao S > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://sourceforge.net/mailarchive/forum.php?forum=cgi-session-user/attachments/20060620/d328597e/attachment.html > > ------------------------------ > > Message: 2 > Date: Tue, 20 Jun 2006 15:58:32 +1000 > From: Ron Savage <ro...@sa...> > Subject: Re: [Cgi-session-user] Hi Sir > To: List - CGI-Session <cgi...@li...> > Message-ID: <2006620155832.491237@MONASH-7ADADE6D> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, 20 Jun 2006 09:56:45 +0530, Srinivasa Rao wrote: > > Hi > > > use CGI::Session; > > use CGI qw/:standard/; > > $session = new CGI::Session(); > > $session = CGI::Session -> new(). > > This is a good habit to get in to, and the difference matters when you > start > using inheritance. > > > my $CGISESSID = $session->id(); > > print header(); > > print start_html(); > > print '<form id="MainForm" method="Post" width="200px" >'; > > $session->param('f_name', 'Sherzod'); > > $session->param(-name=>'l_name', -value=>'Ruzmetov'); > > my $f_name = $session->param('f_name'); > > my $l_name = $session->param(-name=>'l_name'); > > print '<input type=button value=FWD onclick="Action()">'; > > print '<script language="Javascript">'; > > print 'function Action() > > { > > document.forms(0).action=" s.pl?'.$session->name.'='.$CGISESSID.'"; > // > > Here the Session values > are getting stored as querystring > > No they are not. You're using single quotes in the print statement, so > $CGISESSID is not interpolated. > > > document.forms(0).submit(); > > }' ; > > Instead, use qq. E.g.: > > print qq|function ......|; > > > print '</script>'; > > print end_html(); > > Please send all replies to the list. > -- > Ron Savage > ro...@sa... > http://savage.net.au/index.html > > > > > > ------------------------------ > > > > ------------------------------ > > _______________________________________________ > Cgi-session-user mailing list > Cgi...@li... > https://lists.sourceforge.net/lists/listinfo/cgi-session-user > > > End of Cgi-session-user Digest, Vol 2, Issue 7 > ********************************************** > |
From: Ron S. <ro...@sa...> - 2006-06-20 06:02:35
|
On Tue, 20 Jun 2006 09:56:45 +0530, Srinivasa Rao wrote: Hi > use CGI::Session; > use CGI qw/:standard/; > $session = new CGI::Session(); $session = CGI::Session -> new(). This is a good habit to get in to, and the difference matters when you start using inheritance. > my $CGISESSID = $session->id(); > print header(); > print start_html(); > print '<form id="MainForm" method="Post" width="200px" >'; > $session->param('f_name', 'Sherzod'); > $session->param(-name=>'l_name', -value=>'Ruzmetov'); > my $f_name = $session->param('f_name'); > my $l_name = $session->param(-name=>'l_name'); > print '<input type=button value=FWD onclick="Action()">'; > print '<script language="Javascript">'; > print 'function Action() > { > document.forms(0).action=" s.pl?'.$session->name.'='.$CGISESSID.'"; // > Here the Session values are getting stored as querystring No they are not. You're using single quotes in the print statement, so $CGISESSID is not interpolated. > document.forms(0).submit(); > }' ; Instead, use qq. E.g.: print qq|function ......|; > print '</script>'; > print end_html(); Please send all replies to the list. -- Ron Savage ro...@sa... http://savage.net.au/index.html |
From: Srinivasa R. <sri...@gm...> - 2006-06-20 04:26:46
|
My Name is Srinivas, I am devloping a CGI application using Perl. I am using CGI::Session module,here i am facing a problem, i am not able to retrieve the session values from one page to anther page.Could u please help me out.My program is below First Page use CGI::Session; use CGI qw/:standard/; $session = new CGI::Session(); my $CGISESSID = $session->id(); print header(); print start_html(); print '<form id="MainForm" method="Post" width="200px" >'; $session->param('f_name', 'Sherzod'); $session->param(-name=>'l_name', -value=>'Ruzmetov'); my $f_name = $session->param('f_name'); my $l_name = $session->param(-name=>'l_name'); print '<input type=button value=FWD onclick="Action()">'; print '<script language="Javascript">'; print 'function Action() { document.forms(0).action="s.pl?'.$session->name.'='.$CGISESSID.'"; // Here the Session values are getting stored as querystring document.forms(0).submit(); }' ; print '</script>'; print end_html(); Second Page S.pl use CGI qw(:standard); use CGI::Session; print header; print start-html(); my $name; my $value; if (length ($ENV{'QUERY_STRING'}) > 0){ my $buffer = $ENV{'QUERY_STRING'}; my @pairs = split(/&/, $buffer); ($name, $value) = split(/=/, $pairs[0]); } my $session = new CGI::Session( $value); print $session->name; print $session->id; print $session->param('f_name'); print end-html(); Regards Srinivasa Rao S |
From: Sherzod R. <she...@ha...> - 2006-06-17 03:12:13
|
-----Original Message----- From: Sean Coady [mailto:coa...@ho...]=20 Sent: Friday, June 16, 2006 4:50 AM To: she...@cp... Subject: CGI::Session issue Hi Sherzod, I've been trying to set up CGI::Session to work with MySQL, but the = retrieve method always fails when fetching the session given an id. The end = result is that I keep getting a new session ID every time--not very helpful. I can = see from the DBI trace that the REPLACE is working, and it's definitely = going into the db, but the call "my $data =3D $dbh->selectrow_array(qq|SELECT a_session FROM $TABLE_NAME WHERE id=3D?|, undef, $sid);" in CGI::Session::MySQL.pm is returning the empty string for $data. One thing I noticed (it may be unrelated but important nonetheless) is = that it's impossible to create the table in MySQL as follows: CREATE TABLE sessions ( id CHAR(32) NOT NULL PRIMARY KEY, a_session TEXT NOT NULL ); MySQL silently converts all chars to a varchar in the following circumstance: "If any column in a table has a variable length, the entire row becomes variable-length as a result. Therefore, if a table contains any variable-length columns (VARCHAR, TEXT, or BLOB), all CHAR columns = longer than three characters are changed to VARCHAR columns." http://dev.mysql.com/doc/refman/5.0/en/silent-column-changes.html you end up with a table like this: mysql> desc sessions; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | id | varchar(32) | | PRI | | | | a_session | text | | | | | +-----------+-------------+------+-----+---------+-------+ |
From: Mark S. <ma...@su...> - 2006-06-15 11:15:38
|
On Wed, Jun 14, 2006 at 03:41:57PM -0600, Justin Simoni wrote: > > Justin Simoni > -- > :: is an eccentric artist, living and working in Denver, Colorado > :: URL: http://justinsimoni.com I just thought I'd "out" Justin, who just posted a question, as having one of the interesting public uses of CGI::Session. He bundles it as part of DadaMail, web-based mailing list software with a reputation for being easy to install and use, with a growing number of features: http://mojo.skazat.com/ (DadaMail is GPL). DadaMail is being used at this very moment to send out the updates for the Race Across America, which is underway: http://www.raceacrossamerica.org/ It's a non-stop bike race from San Diego to Atlantic City. You could also call it an exercise in sleep deprivation, as the fastest cyclists may sleep about an hour a day, while clocking close to 500 miles in 24 hours... This race route actually comes right through my town here in Richmond, Indiana, and I'm looking forward seeing if I can meet some of these cyclists as they pass through. Mark |
From: Ron S. <ro...@sa...> - 2006-06-14 23:03:46
|
On Wed, 14 Jun 2006 15:41:57 -0600, Justin Simoni wrote: Hi Justin > I'm still trying to tweak my old-session-file-remover thingy, it > currently looks like this (I'm on CGI::Session 4.13) CPAN is your friend. See also CGI::Session::ExpireSessions. -- Cheers Ron Savage, ro...@sa... on 15/06/2006 http://savage.net.au/index.html Let the record show: Microsoft is not an Australian company |
From: Matt L. <mle...@cp...> - 2006-06-14 22:37:40
|
On 6/14/06, Justin Simoni <ju...@sk...> wrote: > sub remove_old_session_files { > > my $self = shift; > require CGI::Session; > > # As of version 4.14 of CGI::Session... > #find( $dsn, \&code, \%dsn_args ) > CGI::Session->find(undef, \&purge_cgi_sess, {Directory=>$TMP}); > > sub purge_cgi_sess { > my ($session) = @_; > next if $session->empty; # <-- already expired?! > if ( ($session->ctime + 3600*48) <= time() ) { > $session->delete() > or warn "couldn't remove " . $session->id . ": > " . $session->errstr; > } > } > } Just a note: I'd suggest not declaring a subroutine within the body of another subroutine. > This is basically lifted off the CPAN docs, again. Thanks for the > notes on the various parameters you can pass to find(). > > One problem I do have, is on one install, the following error happens: > > Can't locate object method "empty" via package "CGI::Session" > > Removing the, > > next if $session->empty; # <-- already expired?! > > Seems to get rid of this error. > > Should this be, > > next if $session->is_empty; # <-- already expired?! > Yes, it should. I thought I fixed this; however, I obviously didn't. Patch has been applied to SVN. Thanks -Matt LeBlanc |
From: Justin S. <ju...@sk...> - 2006-06-14 21:42:13
|
Hey ya'll, I'm still trying to tweak my old-session-file-remover thingy, it currently looks like this (I'm on CGI::Session 4.13) [snip] sub remove_old_session_files { my $self = shift; require CGI::Session; # As of version 4.14 of CGI::Session... #find( $dsn, \&code, \%dsn_args ) CGI::Session->find(undef, \&purge_cgi_sess, {Directory=>$TMP}); sub purge_cgi_sess { my ($session) = @_; next if $session->empty; # <-- already expired?! if ( ($session->ctime + 3600*48) <= time() ) { $session->delete() or warn "couldn't remove " . $session->id . ": " . $session->errstr; } } } [/snip] This is basically lifted off the CPAN docs, again. Thanks for the notes on the various parameters you can pass to find(). One problem I do have, is on one install, the following error happens: Can't locate object method "empty" via package "CGI::Session" Removing the, next if $session->empty; # <-- already expired?! Seems to get rid of this error. Should this be, next if $session->is_empty; # <-- already expired?! ? I couldn't find a method called, "empty" anywhere in the CGI::Session source, but there is, "is_empty". Cheers, Justin Simoni -- :: is an eccentric artist, living and working in Denver, Colorado :: URL: http://justinsimoni.com :: PHO: 720.436.7701 :: Mailing List - http://justinsimoni.com/mailing_list.html |
From: Mark S. <ma...@su...> - 2006-06-11 11:39:51
|
CGI::Session 4.14 is how headed towards CPAN. The following are the changes since the last release. Special thanks to Matt LeBlanc, Ron Savage, and all of the bug reporters for helping with this release. Mark 4.14 - Sunday, June 11, 2006 * NEW: The find() command now has better documentation. (Ron Savage, Matt LeBlanc) * FIX: find() no longer changes the access or modified times (RT#18442) (Matt LeBlanc) * FIX: param() called with two parameters now returns the value set, if any (RT#18912) (Matt LeBlanc) * FIX: driver, serializer, and id generator names are now untainted (RT#18873) (Matt LeBlanc) * INTERNAL: automatic flushing has been documented to be unreliable, although it was recommended in the past. Automatic flushing can be affected adversely in persistent environments and in some cases by third party software. There are also some cases in which flushing happened automatically in 3.x, but quit working with 4.x. See these tickets for details. http://rt.cpan.org/Ticket/Display.html?id=17541 http://rt.cpan.org/Ticket/Display.html?id=17299 |