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.


In reply to Re: Sessions problems by dorward
in thread Sessions problems by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.