Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight


by titanic_fanataic (Acolyte)
on Jan 13, 2005 at 07:57 UTC ( #421908=perlquestion: print w/replies, xml ) Need Help??

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

Hi... I'm just trying to create a login/logout system for one of my scripts, and I have the login part done fine, but I'm having difficulties figuring out how to use cookies to make a logout button for my page that actually works (ie: you can't press back after pressing logout, you have to login again)???

If anyone could describe to me with snippets of code how I would implement something like this into my own program, that would be greatly appreciated.

Thanks for the help,

Replies are listed 'Best First'.
Re: Login/Logout
by nite_man (Deacon) on Jan 13, 2005 at 12:39 UTC

      Logging out seem difficult. I could stay logged in for eternity?

        The common approach is to have a timeout/end date and/or a date of last contact stored in your session. If the timeout or date of last contact is too long ago, the session is considered invalid and you need to enter your password again.

        Many thanks, Connon, I will comply. Actually I'm 'beewarb' not registered, {but I thought I was!} beewarb

      I would love to use these methods, but unfortunately, I don't have access to any of these mods on my server. I would have to use either cookies or hidden form feilds. In this case I believe that it would be wise to use cookies... Could someone point me in the right direction for a turorial on this...


Re: Login/Logout
by r34d0nl1 (Pilgrim) on Jan 13, 2005 at 11:33 UTC
    If you are using cookies it is a good practice to check every page if the cookie content is Ok.
    In the logout page you can clean the cookie or send, for example, the LOGGED=False value to the cookie.
    Next Time the page is loaded (even with the back button) the content of the cookie will be checked and will be invalid.
    This node explains about cookies and how to 'delete' them.
    Hope it can help you.
Re: Login/Logout
by rdfield (Priest) on Jan 13, 2005 at 09:55 UTC
    Create your pages with "no-cache" set and with the expires time sometime in the past. Every time the browser is asked to display the page it has to go back to the server. In theory. You've got no control over the caching between your server and the client (there may be proxy caches in the way) - you can only request that they don't cache the page.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-08-04 22:28 GMT
Find Nodes?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)

    Results (43 votes). Check out past polls.