| perl and CGI::Session
|
Anadon

msg:4322597 | 7:44 pm on Jun 6, 2011 (gmt 0) | Hi, I'm trying to use the CGI:Session module to handle session data and I must be doing something very daft as I just cant seem to generate a session id to add to the query strings I'm generating further on in the script. I've looked at the cpan tutorial and it looks to me like the following code should generate the session strings i need. use CGI::Session; $session = new CGI::Session("driver:File",undef,{'Directory'=>"/tmp"}); $html_session = $session->id(); Instead I get the dreaded 500 error and the apache log file contains: main.pl: Can't call method "id" on an undefined value at C:/wwwroot/cgi-bin/main.pl line 59 Any help would be greatly appreciated. Thanks
|
janharders

msg:4322600 | 7:53 pm on Jun 6, 2011 (gmt 0) | Try calling CGI::Session->errstr() after you initialize the object. CGI::Session's new() will return undef if an error occurs, so you'll have to check for that, like
if(my $session = CGI::Session->new(...)) { ... normal code goes here } else { print CGI::Session->errstr(); }
Of course that assumes that you've printed the http headers before this. Otherwise, just add them before printing the errstr()
|
phranque

msg:4322681 | 12:18 am on Jun 7, 2011 (gmt 0) | does the server have write access to the /tmp directory?
|
Anadon

msg:4322760 | 8:06 am on Jun 7, 2011 (gmt 0) | Thanks for the help, once I could see the error returned it was fairly obvious what I'd done - I hadn't installed the CGI::Sessionb module properly and there was a driver file missing. Thanks
|
|
|