Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hello Monks...

May i ask for 10nanoseconds of your wisdom, please???

I am having a small problem with CGI::Session and i am stuck... (for 3 days now)

I have an html page (login.html) that asks for user and password. When entered, login.pl checks for them, if they are correct then it creates a sesion and launches web.pl

web.pl checks if the session is valid. if so, then it shows the webpage but if not, it redirects to login.html

The problem is that it seems that the session created by $sesion=new CGI::Session(); is always empty when checked by web.pl . why???

Curiously, if the user enters the process twice (with correct credentials of course) then it works!!!

login.pl:
#!/usr/bin/perl use warnings; use CGI; use CGI::Session; $cgi=new CGI; if (CredentialsOK($user,$pwd)){ $sesion=new CGI::Session(); $sesion->param('userlogged',$user); print $sesion->header(-location=>"web.pl"); $sesion->flush(); } else { print $cgi->redirect(-uri=>"login.html"); }
web.pl
#!/usr/bin/perl use warnings; use CGI; use CGI::Session; use HTML::Template; $cgi=new CGI; $sesion=CGI::Session->load($cgi); $plantilla=HTML::Template->new(filename => 'web.html'); $sesion=CGI::Session->load(); if (($sesion->is_expired) || ($sesion->is_empty)) { print $cgi->redirect(-uri=>"login.html"); } else { print $cgi->header(); print $plantilla->output(); }

Thanks to all in advance!!

Pedrete.

In reply to CGI::Session small problem... by pedrete

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (8)
    As of 2014-07-23 09:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (138 votes), past polls