Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: IDK <ulvinge@xxxxxxxxx>
- Date: Thu, 28 Jun 2007 23:18:03 -0000
On Jun 29, 12:44 am, gautam chekuri <gautam.chek...@xxxxxxxxx> wrote:
On Jun 29, 3:19 am, "J. Gleixner" <glex_no-s...@xxxxxxxxxxxxxxxxxxxxx>
wrote:
IDK wrote:
$session = new CGI::Session("driver:postgresql;id:md5", undef,
{Handle=>$dbh, ColumnType=>"binary"});
I don't use it, however to try to help you, I scanned the
documentation for the current CGI::Session on CPAN and this
might be of interest:
Following data source components are supported:
driver - CGI::Session driver. Available drivers are file, db_file, mysql
and sqlite.
If there is a driver for PostgreSQL, it's not mentioned.
Also,
SUPPORT
If you need help using CGI::Session consider the mailing list. You can
ask the list by sending your questions to
cgi-session-u...@xxxxxxxxxxxxxxxxxxxxx .
You can subscribe to the mailing list athttps://lists.sourceforge.net/lists/listinfo/cgi-session-user.
{Handle} doesn't seem to get to init, and as I'm not very good at
perl, I don't know why...
Either do we.
There's no mention of Handle or ColumnType in the documentation, that I
could see.
The dbh handle is working, and I've written the session code exactly
as instructed by
the docs, so my conclusion is that either the docs or libraries are
wrong. But I may have misinterpreted the docs...
Post a short example. <10 lines should cover it. We don't need to
see the code from CGI::Session, only your code and what errors
you receive.
well.. the pgsql driver is a third party implementation based on
CGI::Session::Driverhttp://search.cpan.org/~sherzodr/CGI-Session-4.10/lib/CGI/Session/Dri...
Niklas, as suggested by J.G a short example ( without typos etc.. )
would be very helpfull..
i would suggest you turn on strict and warnings in this example..
Such small examples act as test cases, that help in understanding the
problem...
for eg, I did this and I see that things are working fine :
[root@deepdark gautam]# cat ./session.pl
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Session;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=test;host=localhost;port=5432",
"USERNAME", "");
if ( !defined $dbh ) {
die "Cannot connect to database!\n";
}
my $session = new CGI::Session(
"driver:postgresql:id:md5",
undef,
{
Handle => $dbh,
ColumnType => "binary",
}
);
How can the above code work?
"driver:postgresql:id:md5" should be "driver:postgresql;id:md5".
Atleast as I interpret the docs...
The postgres driver is included my package.
With strict I only get loads of:
login: Global symbol "$s" requires explicit package name at ./login
line 25.
And I always has warn on.
Here's all my code:
****************************** login *************************
#!/usr/bin/perl -w
use funcs;
use Digest::SHA1 qw(sha1_base64);
#use strict;
makeHTML('register');
if(!param('user')){
print '<form name="input" action="login" method="post">
Username: <input type="text" name="user"><BR>
Password: <input type="password" name="password"><BR>
<input type="submit" value="Submit">
</form>';
}else{
$user = param('user');
$pass = param('password');
$digest = sha1_base64($pass);
$s = sqlQuerry("SELECT id, pass FROM zerus.players WHERE
name='$user'")
or die "cannot prepare";
@data = $s->fetchrow();
if($data[1] eq $digest){
print "\n<H1>You've successfully logged on</H1>\n"
} else {
print "\n<H1>Wrong password, or no user with that name</H1>
\n"
}
$s->finish or die "Cannot finnish";
}
finnishUp();
********************************** funcs.pm
************************************
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
use DBI;
#use Apache::Session::Postgres;
use DBD::Pg qw(:pg_types);
use CGI::Session;
use CGI::Session::Driver::postgresql;
use CGI::Session::ID::md5;
use CGI::Session::Serialize::default;
sub openDB
{
#open db
$dbh = DBI->connect("dbi:Pg:dbname=zerus;host=localhost;port=5432",
"*", "*");
if ( !defined $dbh ) {
die "Cannot connect to database!\n";
}
}
sub makeHTML
{
# Get the CGI form data
print "<HTML><TITLE>${_[0]}</TITLE><BODY bgcolor='\#000000'
text='\#aaa666'>";
}
sub sqlQuerry
{
$sth = $dbh->prepare($_[0]);
if ( !defined $sth ) {
die "Cannot prepare statement: $DBI::errstr\n";
}
$sth->execute;
$sth;
}
sub finnishUp
{
print end_html();
print $@, "<BR>\n";
if(defined($DBI)){ print $DBI::errstr, "<BR>\n"; }
eval { $dbh->disconnect; };
}
openDB;
$session = new CGI::Session("driver:postgresql;id:md5", undef,
{Handle=>$dbh, ColumnType=>"binary"});
$CGISESSID = $session->id();
# send proper HTTP header with cookies:
print $session->header();
#$cgi = new CGI;
#print header();
*************************************************************************
If I replace all the session stuff with the commented out stuff, I get
no
errors.
This is the output:
Set-Cookie: CGISESSID=d07adf2adfd6ded310af61f101c1bed1; path=/
Date: Thu, 28 Jun 2007 23:13:37 GMT
Content-Type: text/html; charset=ISO-8859-1
<HTML><TITLE>register</TITLE><BODY bgcolor='#000000'
text='#aaa666'><form name="input" action="login" method="post">
Username: <input type="text" name="user"><BR>
Password: <input type="password" name="password"><BR>
<input type="submit" value="Submit">
</form>
</body>
</html><BR>
[Fri Jun 29 01:13:37 2007] login: (in cleanup) Can't connect to
data source '' because I can't work out what driver to use (it doesn't
seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is
not set) at /usr/share/perl5/CGI/Session/Driver/DBI.pm line 26
[Fri Jun 29 01:13:37 2007] login: (in cleanup) Can't call method
"commit" on unblessed reference at /usr/share/perl5/CGI/Session/Driver/
DBI.pm line 130 during global destruction.
*************************************************************
.
- Follow-Ups:
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: Joe Smith
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- References:
- new in CGI::Session::Driver::postgredsql nonexisting
- From: IDK
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: goodgautam
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: IDK
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: J. Gleixner
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: IDK
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: gautam chekuri
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: IDK
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: J. Gleixner
- Re: new in CGI::Session::Driver::postgredsql nonexisting
- From: gautam chekuri
- new in CGI::Session::Driver::postgredsql nonexisting
- Prev by Date: Re: new in CGI::Session::Driver::postgredsql nonexisting
- Next by Date: Re: DBIx::Simple, fails with no error (not CGI this time!)
- Previous by thread: Re: new in CGI::Session::Driver::postgredsql nonexisting
- Next by thread: Re: new in CGI::Session::Driver::postgredsql nonexisting
- Index(es):
Relevant Pages
|
|