Disclaimer: haven't read or tried to follow the whole thread.

$query{$sessionname} is trying to access the value of a key in %query, which is not defined in the scope.

Maybe you meant $query->{ $sessionname } which accesses the value of a key in the hashref $query.

But that won't work either since what you seem to be actually trying to access is the object in $query, not a hashref nor a hash of the same name. See the next line where you correctly access the value returned by $query's object method param() with an argument of $sessionname.

There are other questionable things in this code, for example elsif(scalar$query) -- this is unnecessary (you must have done my $query = CGI->new ... somewhere above, right?) and calling scalar() on a scalar is meaningless.

I don't know whether you wrote all this, or copied it from somewhere, or assembled it from things you've found in various places, but it's a mess, and that's obvious without reading the start of this thread. You badly need to read -- and understand -- quite a bit of documentation. See the Perl Data Structures Cookbook, CGI, for starters.

Also, since you have chosen the CGI route, review Ovid's CGI Course - Resurrected and Updated!

And as more generalized friendly suggestions I offer: (1) Dump your IDEs and learn to write Perl code on the command line and in plain text files. (2) Set up a webserver on your local machine so you can test your code locally and don't have to worry about "uploading" and "downloading" anything until it works.

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re^9: Sessions Questions by 1nickt
in thread Sessions Questions by tultalk

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.