Sessions how they works?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Sessions how they works?

Post by killingbegin »

we got 4 pages

index.php-login.php-access1.php-access2.php

you go at index if you have not login head will be login php

but when yu login what you do after?
you start a session and sett session username and session password

when you go at the access 1.php you can make an if stament and see if your data username and password have been set?
or you must using get function variables at every function and if they are in database then you go on?
sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: Sessions how they works?

Post by sparrrow »

It is hard to understand what you are saying or asking. Session variables are stored and accessed on the server, and can only be used by a user during a single browsing session. $_SESSION is a superglobal array that can be accessed anywhere in your code without re-declaring it. You can certainly set the user's username and password as a session var, but you may still want to validate it against your user table on each page load to be sure. You can use isset() to check if the variables have been set. Check out the PHP Manual for Sessions for lots of good info.
Post Reply