[PHP] stay logged in for whole website

liunx

Guest
I have a website with a special area (a couple of pages) only available for users that have succesfully logged in using their username and password.

How can I keep the pages unavailable for view by other users and how can I programm so that users stay logged in during a period?

I suppose it's somehow the same as for this forum? Isn't that done by using cookies?

I'm using php and mysql.cookies and sessions.

what you need to do it check for either one adn if none found they don't get the page but a login page. if they know the username and password then they can log in.yep - cookies and sessions.

look at these links to find out more:

PHP Manual on Sessions (<!-- m --><a class="postlink" href="http://www.php.net/manual/en/ref.session.php">http://www.php.net/manual/en/ref.session.php</a><!-- m -->)

PHP and Sessions (<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=18587&highlight=php+sessions">http://www.htmlforums.com/showthread.ph ... p+sessions</a><!-- m -->)

Difficulties with PHP Sessions (<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=18419&highlight=php+sessions">http://www.htmlforums.com/showthread.ph ... p+sessions</a><!-- m -->)


hope this helps you out (it did me),

HKAs much as cookies seem to be mainstream, I would advise you not to use them. If you do use them, make sure that they are not an integral part of your authentication system.

People can disable cookies on their PC at their will, thus rendering your script nearly useless, dependaing on what you are using them for. As for sessions, they can't touch those. Therefore, sessions are better IMHO because you have total control about how they are being used.thanks. so the best thing would be only to use sessions?
isn't phpbb and this forum working with cookies as well? so this forum won't work without cookies enabled?yes the forum does use cookies, but if you uncheck it then when you close the browser out you will have to relogin again. the cookie is just used to auto-login so you don't have to.
 
Back
Top