Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-25 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found