Saving Session State

Saving Session State

am 06.02.2008 17:52:01 von brett lee

Hello,

With some help from this board I've been able to get my project running well under ModPerl::Registry - am even using two of my own (woopie !) modules, so thanks all. Am now trying to save session state on the server; am again seeking some guidance.

Have tried using CGI::Session (3.95, 4.10, 4.20) but am continually seeing two issues that appear to still be open issues with the latest (is it the final?) release.

In looking around further:

Apache::Session - reviews were not too favorable.
CGI::Application::Plugin::Session - seems to have a large number of requirements.
Catalyst - yeah, probably overkill. :)

I would appreciate any guidance toward a simple session management module that works with "Registry" and Perl 5.8.8.

Thank you.





____________________________________________________________ ________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?categor y=shopping

Re: Saving Session State

am 06.02.2008 20:21:11 von Perrin Harkins

On Feb 6, 2008 11:52 AM, brett lee wrote:
> Have tried using CGI::Session (3.95, 4.10, 4.20) but am continually seeing two issues that appear to still be open issues with the latest (is it the final?) release.

What issues are you having trouble with? Mark is one of the more
responsive CPAN authors around, and my experiences with CGI::Session
have been good.

- Perrin

Re: Saving Session State

am 06.02.2008 21:59:41 von brett lee

>
Have
tried
using
CGI::Session
(3.95,
4.10,
4.20)
but
am
continually
seeing
two
issues
that
appear
to
still
be
open
issues
with
the
latest
(is
it
the
final?)
release.

What
issues
are
you
having
trouble
with?
Mark
is
one
of
the
more
responsive
CPAN
authors
around,
and
my
experiences
with
CGI::Session
have
been
good.

--
That's excellent news - its probably operator error.

1. First problem is that refreshing the screen often (not always) results in a new session being generated:
http://rt.cpan.org/Public/Bug/Display.html?id=17299
With these failures, I can see the browser session in the filesystem, its not expired, but it is not picked up with load().


2. Other one is that I see new session ID's in the browser but not always on the server (filesystem):

http://rt.cpan.org/Public/Bug/Display.html?id=24285


Am using CGI.pm's function-oriented style so I don't have a CGI object. The 4.10 doc for CGI::Session 4.10 shows saving params without an object, but when I try I get an error indicating the first arg has to be an object. So, am using the following:

my $session = CGI::Session->load(undef, undef, {Directory=>'/tmp/sessions'});

if ( $session->is_expired ) {
print "is_expired.
";
$errmsg = "Your session expired. Please refresh your browser to re-start your session";
}
if ( $session->is_empty ) {
print "is_empty.
";
$session = $session->new(undef, undef, {Directory=>'/tmp/sessions'});
$session->expire('+15m');
$session->param('Auth', 'N');
$session->save_param(undef,['Auth']);
}


Also, the 4.10 doc writes:
$session = new CGI::Session(undef, undef, {Directory=>'../tmp/sessions'});

I've tried "../tmp/sessions" and "/tmp/sessions". Have never seen anything in "../tmp/sessions" (relative to "/cgi-bin" or DOC ROOT) but I do see sessions (sometimes) appear in "/tmp/sessions". Happen to know if the syntax is relative (../), or absolute (/)? Note that both of these errors were seen in 4.x. Never got the 3.95 to save an object, but just read that it needs a flush().

Thanks much.













____________________________________________________________ ________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?categor y=shopping

Re: Saving Session State

am 06.02.2008 22:28:24 von Perrin Harkins

On Feb 6, 2008 3:59 PM, brett lee wrote:
> 1. First problem is that refreshing the screen often (not always) results in a new session being generated:
> http://rt.cpan.org/Public/Bug/Display.html?id=17299
> With these failures, I can see the browser session in the filesystem, its not expired, but it is not picked up with load().

That doesn't sound like the bug you linked to. Check that your code
is getting the right session ID from cookies or however you do it in
your app.

> 2. Other one is that I see new session ID's in the browser but not always on the server (filesystem):
>
> http://rt.cpan.org/Public/Bug/Display.html?id=24285

This also doesn't sound related to the bug you're linking to. Most
likely this means you have a scoping problem in your code that
prevents the session object from going out of scope. You can either
fix the scoping issue or call flush().

> Am using CGI.pm's function-oriented style so I don't have a CGI object. The 4.10 doc for CGI::Session 4.10 shows saving params without an object, but when I try I get an error indicating the first arg has to be an object. So, am using the following:
>
> my $session = CGI::Session->load(undef, undef, {Directory=>'/tmp/sessions'});

You are passing undef as your session ID. This will never load
anything. What's the problem with passing your real ID?

> Also, the 4.10 doc writes:
> $session = new CGI::Session(undef, undef, {Directory=>'../tmp/sessions'});
>
> I've tried "../tmp/sessions" and "/tmp/sessions". Have never seen anything in "../tmp/sessions" (relative to "/cgi-bin" or DOC ROOT) but I do see sessions (sometimes) appear in "/tmp/sessions". Happen to know if the syntax is relative (../), or absolute (/)?

I never use file-based sessions. I suggest using a database. It's a
lot more common and thus better tested.

- Perrin