Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

My first website

by c (Hermit)
on Jan 26, 2002 at 03:52 UTC ( #141692=perlmeditation: print w/replies, xml ) Need Help??

Hello all. I'm not sure who slipped the drugs in my tea today, but I somehow got roped into making a website that is fully session based with users authenticating through a mysql db. Up until now, I've been a dude using perl for my cisco/bgp needs, so I'm in a brand new ballpark. Any suggestions on a very introductory book on working with session based web sites using our favorite language?

humbly -c

Replies are listed 'Best First'.
Re: My first website
by Ryszard (Priest) on Jan 26, 2002 at 06:17 UTC
    Doing session management is easy. For a start you'll need a table that has the usernames/passwords, and a table that will store the session id.

    Next you set up a (HTML) page that will allow the user to enter their name and password. This is done by using a form with a submit button on it. (it can be quickly knocked up in frontpage, (or vi) )

    You then get the user's name when they press the submit button and check for naughty characters (taint checking).

    You then go get the password from the database basaed on the username.

    Compare retrieved pwd with the supplied pwd, and set a cookie with a unique sess_id (and stick the sess_id into the session table with an expiry time).

    For each user initiated action, (after taint checking all the inputs) you go check to see if the session is still alive. If the session is dead, send back the login page, otherwise let the user do what they requested.

    Make sure you use, CGI::Application, HTML::Template, perl -wT and strict for your application.. :-)

    As for books, check out the O'Reilly DBI book, and have a look at the Perl CD bookshelf, its expensive, but invaluable, and has stuff from beginers to advanced. For OOP, Object Oriented Perl by Conway is a must have.

    Good Luck!

Re: My first website
by screamingeagle (Curate) on Jan 26, 2002 at 04:09 UTC
    I dont know of any book which specifically talks about sessions using Perl;only recommendation i can give is that u look at the following modules which should be helpful :
    a)Apache::Session and
    Here's a link to the relevant documentation: Apache::Session
Re: My first website
by legLess (Hermit) on Jan 26, 2002 at 12:34 UTC
    Since no one else actually talked about a book ... I'd recommend the O'Reilly "mouse book" - CGI Programming with Perl, 2nd Edition. I own a copy and it's very good. Typical of O'Reilly, it's dense and complete, with good examples. It's not "Perl CGI Sessions for Dummies," but it was my first CGI book, and I've done well with it.
    man with no legs, inc.
Re: My first website
by dreadpiratepeter (Priest) on Jan 28, 2002 at 21:35 UTC
    Actually, I've been getting incredible results using HTML::Mason.
    The componant model makes development a snap. It does what JSPs and ASPs promise to do. The big win is the granularity of components. Unlike JSPs, they are finer than the page level. You can mix and match simple components to build a web page.
    Also, the nested handlers allow you to easily maintain a consistant look and feel, make your menus and headers work automatically over multiple pages and simplify navigation.
    It's a little work at the beginning to understand the intricasies of the toolkit, but the investment is really worth it. Oh yeah, to answer your question it supports sessions and database connections.
    check out Mason HQ

    Entropy is not what is used to be.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2023-05-30 17:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found