|< 1 2 >| | 18 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sub session_create
{
my ($obj, $dbh, $userid) = @_;
my $mydbh = $dbh;
unless($mydbh) { $mydbh = &libyn::DB::connect_to_db($obj); }
$CGI::Session::MySQL::TABLE_NAME = $libyn::Config::DbTables{sessions};
my $session = CGI::Session->new("driver:MySQL", $obj->{-cgi}, { Handle => $mydbh }) or die "CGI::Session->new failed.";
$session->name('sessionId');
$session->expire('+1h');
$session->param('userId', $userid);
unless($dbh) { $mydbh->disconnect(); }
return $session;
}
1
2
3
4
5
6
CREATE TABLE yn_sessions (
id varchar(32) NOT NULL default '',
a_session text NOT NULL,
userId bigint(20) default NULL,
UNIQUE KEY id (id)
) TYPE=MyISAM;
QuoteDie Werte, die aus den CHAR(4)- und VARCHAR(4)-Spalten abgerufen werden, sind in jedem Fall gleich, weil Leerzeichen am Ende von CHAR-Spalten beim Abruf entfernt werden.
my $session = CGI::Session->new(undef, $obj->{-cgi}, { Directory => 'data/sessions' }) or die "CGI::Session->new failed.";
$CGI::Session::MySQL::TABLE_NAME = $libyn::Config::DbTables{sessions};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use CGI::Carp "fatalsToBrowser";
use CGI qw(:all);
use warnings;
use DBI;
use lib './module';
use strict;
use CGI::Session;
use vars qw($dbms $dbname $dbuser $dbpasswd $session $sid $dbh $lg_name);
require "dbinfo.cgi";
my $cgi = new CGI;
my $dbh = DBI->connect( "$dbms:$dbname","$dbuser","$dbpasswd", {PrintError => 0, RaiseError => 1}) || die
"Verbindung zur Datenbank fehlgeschlagen: $DBI::errstr";
$sid = $cgi->cookie('YAMBE_SESSID') || $cgi->param('YAMBE_SESSID') || undef;
$session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh});
$session->expire('3');
$session->param("USER", $lg_name || 'gast');
my $cookie = $cgi->cookie(YAMBE_SESSID => $session->id );
print $cgi->header(-cookie=>$cookie);
Quote[Mon Aug 21 19:29:28 2006] session.cgi: Use of uninitialized value in numeric eq (==) at C:/Perl/site/lib/CGI/Session/MySQL.pm line 35 during global destruction. [Mon Aug 21 19:29:28 2006] session.cgi: Use of uninitialized value in concatenation (.) or string at C:/Perl/site/lib/CGI/Session/MySQL.pm line 36 during global destruction. [Mon Aug 21 19:29:28 2006] session.cgi: (in cleanup) could not flush: Couldn't acquire lock on id '9065907de0cbdcd1fd81dd7b20c7cc84'. Lock status: at ...\cgi-bin\yambe\data\session.cgi line 0
$CGI::Session::MySQL::TABLE_NAME = 'yn_sessions';
1
2
3
4
CREATE TABLE sessions (
id CHAR(32) NOT NULL PRIMARY KEY,
a_session TEXT NOT NULL
);
|< 1 2 >| | 18 Einträge, 2 Seiten |