in reply to Re^4: CGI::Session - non-stop session creation problem
in thread CGI::Session - non-stop session creation problem
Ok, I think I know what you mean now. You want something like this (doesn't work because CGI::Session doesn't support it):
I'm not entirely clear on the architecture of CGI::Session, but that may need to go into the DSN instead. Anyway, once you tell it not to autocreate new sessions, the code would have to change to honour it.$session = CGI::Session->new(undef, $sid, {Directory=>'C:/apache/sessi +ons',NoCreateIfNotExists=>1});
Another alternative, which I just stumbled upon. Which you may not like for similar reasons as before. I suspect this is how the author of CGI::Session envisions doing what you ask for:
When you get the session, you can check if it's a new session or not. If it is, you can delete it. From what I can tell reading the code, this won't hit your hard disk at all. And the fact that the is_new sub is there at all says to me that this is the author's idea of solving this very problem.my $sid = $foo->cookie('main') || undef; my $session; # = undef if (defined $sid) { $session = CGI::Session->new(undef, $sid, {Directory => 'c:/apache/s +essions'}); $session->delete() if $session->is_new(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: CGI::Session - non-stop session creation problem
by ikegami (Patriarch) on Apr 08, 2005 at 05:58 UTC | |
|
Re^6: CGI::Session - non-stop session creation problem
by Stenyj (Beadle) on Apr 07, 2005 at 22:28 UTC |