jeyabal has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, For past 8 months am working with perl command line programing. Now I need to create web programs using Perl CGI. I need help in creating session or cookies and maintaining through out the linked web pages. Following is my web page design. 1(DONE it). I will enter username and password in login window ("Login.html") and it will be passed to "Page1.cgi" using POST method. 2(Need help). In "page1.cgi" I need to check the credentials passed and create session for the logged in user and navigate to "page2.cgi". 3. From page2, I will navigate to some other pages. 4(Need help). I need the session to be expired for an idle minute or by users intention to logout the session. 5(Need help). I need to check the session in all pages whether its exist or expired. Please help me with above queries. Thanks, Jeyabal

Replies are listed 'Best First'.
Re: CGI Session creation and checking
by marto (Cardinal) on Dec 06, 2010 at 11:21 UTC

    Have you looked at the CGI::Session (see also CGI::Session::Tutorial)? This should take care of your session issues. In step 2 what are you checking the credentials against? A database?

    If you are new to CGI programming it's worth while reading and understading Ovid's CGI Course.

      Thanks for your reply. Regarding the credentials, for now and using constants.
Re: CGI Session creation and checking
by locked_user sundialsvc4 (Abbot) on Dec 06, 2010 at 14:45 UTC

    Jeyabal, there is probably no one here who has not been in exactly the same situation as you.   My best advice is that you stop for a few days and start vacuuming-up just as many tutorials as you can find.   Look at frameworks and helpers, from stuff as simple as CGI::Application and as sophisticated and all-inclusive as mod::Catalyst.   The temptation is to bang your head against what you do not yet know.   Do not waste your own time and energy in this way... even though every single one of us has.   These lessons have already been learned, and good solutions and techniques have already been built.   But to discover them, you first have to tell yourself to stop what you’re now doing for a couple days; maybe a week.

    As Douglas Adams wrote:   “Don’t Panic!™”   Even though you think the pressure is on and that “not doing something” is only putting you farther behind ... the exact opposite is true.

    You will be “taking a sip from a firehose.”   (Don’t let the water hit you in the face.)   Skim the things that you encounter and build lots of web bookmarks.   Gradually, a pattern will begin to emerge from the gloom, and that is what you are looking for.   You’ll see the same problems being solved, over and over again.   The solution is different but the problem is the same and the objective is the same.   Once you recognize the problem, you can identify and explore the various CPAN tools that are available ... and, since you now understand what the problem is, the tools make sense.   You need to build up that knowledge-base, by lots and lots of skimming, to get a clear picture of how these problems are solved (and have been solved, literally tens of thousands of times before).   Remember... although this is “baffling and new” to you, it is not new.

      ^ I agree, but now I'm stuck having tried to implement one of the packaged solutions, and having incomplete success. I can't find where the problem is. I made an earlier post about it (Apache::Session::MySQL) and have gotten no response. So there's a trade off between exhausting oneself trying multiple prebuilt solutions only to fail at implementing them and starting with a new one each time and the choice of DIY. I know better than to DIY on something like this, but i'm already on my third attempt with a different set of modules. :(
Re: CGI Session creation and checking
by perl_lover (Chaplain) on Dec 06, 2010 at 11:22 UTC
Re: CGI Session creation and checking
by scorpio17 (Canon) on Dec 06, 2010 at 14:24 UTC
    Some time ago I started a tutorial on how to use CGI::Application to create a simple login page. It never made it past the "request for comments" stage, but you can still find it here.