[Cgi-session-user] perl 5.8.7 and cgi::session 4.03
Brought to you by:
sherzodr
From: Cristi O. <cr...@wi...> - 2006-01-18 15:07:26
|
Hi all, Again, my "fellow" admin from the server I host two of my clients' sites has upgraded the version of perl to 5.8.7 and CGI::Session module to 4.03. This leads to several problems regarding my websites. First was that the sessions refused to initialize, but this I solved. Now I have a nightmare because I have nothing written inside the session files. It is incredible, because it WORKED fine until the upgrade. I revised several times my code and nothing seems to be wrong, but. Please tell me if there are incompatibilities between perl 5.8.7 and CGI::Session 4.03. Anyway my code is as follows: (maybe you can find my error) ============================================================================ ======= #!/usr/bin/perl use CGI; my $q = new CGI; use setup; use CGI::Session; my $sid = $q->cookie('CGISESSID') || undef; $session = new CGI::Session(undef, $sid, {Directory=>$setup::director_sesiuni}); $sid = $session->id(); $utilizator = $session->param("utilizator"); $id_utilizator = $session->param("utilizator_id"); $tip_utilizator = $session->param("utilizator_tip"); $session->expire('+30m'); if ($utilizator ne ''){ print $q->header(-expires=>'1s'); } if ($utilizator eq ''){ $cookie = $q->cookie(-name=>$session->name, -value=>$session->id, -expires=>"+6h"); print $q->header( -cookie=>$cookie, -expires=>'1s' ); } I (try to) write into the session file using this code: #!/usr/bin/perl use CGI; my $q = new CGI; use setup; my $pag = $q->param('pag'); use CGI::Session; my $sid = $q->cookie('CGISESSID') || undef; my $session = new CGI::Session(undef, $sid, {Directory=>$setup::director_sesiuni}); $sid = $session->id(); $cookie = $q->cookie(-name=>$session->name, -value=>$session->id, -expires=>"+1d"); print $q->header( -cookie=>$cookie, -expires=>'1s' ); my $adresa = $setup::cale; use Digest::MD5 qw(md5_hex); use DBI; my $dbh = DBI->connect("dbi:mysql:database=$setup::database",$setup::username,$setup:: password,{RaiseError=>1}); ===== snip ====== if ($gigi == 1){ my $sth1 = $dbh->prepare("SELECT id, nume, confirmat, tip_user FROM utilizator WHERE (utilizator.username = ?) AND (utilizator.parola = ?)"); $sth1->execute($user,$passcrypt); while (my @row1 = $sth1->fetchrow_array()){ if ($row1[2] == 1){ $id_utilizator = $row1[0]; $gigi = 1; $session->param("utilizator", $row1[1]); $session->param("utilizator_id", $row1[0]); $session->param("utilizator_tip", $row1[3]); }else{ $gigi = 2; } } } =============================================== Thanks in advance for any tip. Cristi Ocolisan |