Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Sessions problems

by dorward (Curate)
on Dec 13, 2006 at 10:09 UTC ( [id://589534]=note: print w/replies, xml ) Need Help??


in reply to Sessions problems

I think you mean CPAN rather than CSPAN.

The first thing to do is:

use strict; use warnings;

That will catch a number of issues with your code.

I keep getting the error "Can't call method "cookie" on an undefined value"

In the line:

my( $session, $query, $cookie, $name, $cgi);

You create a scalar called "$query", but you don't assign a value to it. By the time you use it two (non-blank, non-comment) line later, you still haven't assigned a value to it.

Judging from the methods you are calling on it, I think you want it to be a CGI object. You create one earlier in the script.

 $q = new CGI;

So just reuse that instead of creating another one. (Note that you'll need to move the line, otherwise you'll run into problems since it won't be created if the request isn't POST (there would also be scoping issues if you were following the normal practise of using strict/warnings and scoping the variable with my).

I am not sure if the place that i put the session in my code effects how it runs? I have it stored after the params are read in from the form submitted by the user, but before checks are done to validate those params submitted by the user.

I wouldn't create the session until I knew the credentials were good. That way, if the session exists then you know you've already checked the credentials and you don't need to check them with every single request.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://589534]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found