Ok, I think I know what you mean now. You want something like this (doesn't work because CGI::Session doesn't support it):

$session = CGI::Session->new(undef, $sid, {Directory=>'C:/apache/sessi +ons',NoCreateIfNotExists=>1});
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.

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:

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(); }
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.


In reply to Re^5: CGI::Session - non-stop session creation problem by Tanktalus
in thread CGI::Session - non-stop session creation problem by Stenyj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.