[Cgi-session-user] CGI::Sesion works incorrectly
Brought to you by:
sherzodr
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; |