Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

CGI perl

by rjsaulakh (Beadle)
on May 26, 2005 at 12:19 UTC ( #460637=perlquestion: print w/replies, xml ) Need Help??

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

i have a login page in shtml where a user logs in with his username and password .

i need to take care of session variable and for that i need to write a perl/cgi script which can take care of session variable and store it in database form on the server

the session variable to be taken care of are

1. Login name
2. password
3. time of login
4. time of logout
5. history of his login session
working on widows box

can i get any help how to proceed with it i am trying with CGI::Session. Please help me

Replies are listed 'Best First'.
Re: CGI perl
by Fletch (Chancellor) on May 26, 2005 at 12:27 UTC

    Well, judging by the code you've shown . . . oh, never mind.

    Hint: Show effort, show what you've tried, and don't repost the same question three frelling times. No one here is going to write your script for you.

      use CGI::sesssion::File; use CGI; my $cgi = new CGI; my $sid = $cgi->cookie(SESSION_COOKIE) || $cgi->param("sid") || undef; //creating a new session my $session = new CGI::Session::File(undef {LockDirectory=>"/tmp", Directory=>"/tmp"}) or die $CGI::Session::errstr; print "Your session id is ", $session->id(); // A cookie is being created which is then being send to the user brow +ser $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); $session->save_param($cgi, ["login_name", "password"]);

      i have tried to write this bit of code in which i try to collect the session variables from a HTML page and store in a database

      but i have few queries still 1. will my script run on windows or have to make some changes.
      2. there are some default session parameters values
      _sessio_id, _session_ctime, _session_atime, _session_etime
      how can i store this into the same database where my sessionid , loginname and password resides can i set the expiration time for a user

Re: CGI perl
by xorl (Deacon) on May 26, 2005 at 12:33 UTC

    From what I can tell the following links tell you everything you need to know:

    I know this is blasphemy around here, but IMHO for any web application that needs some kind of session PHP is much better than Perl at handling it.

      I won't comment on Perl Vs PHP for handling sessions (since I've never written anything in Perl that uses sessions), but PHP does have insane default settings for its session handling. IIRC the developers won't change the defaults because they are terrified that browsers won't be able to handle HTML without any errors in it.

        I've just read that referenced node. Are you kidding me? PHP doesn't entitize the HTML in a link? Amazing. It's simply crazy that PHP hasn't fallen over with all the bad things still being done in it.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

Re: CGI perl
by fireartist (Chaplain) on May 26, 2005 at 15:06 UTC

    Are you sure a cgi script called via SHTML can get and set cookies?

        Well, I was pretty sure, but not certain! (And didn't have time to enable shtml on my server, etc...)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://460637]
Approved by Mutant
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2022-01-24 19:24 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (65 votes). Check out past polls.