I have read lots of articles about php sessions but i have a problem applying it to my login | logout | Register | My Profile tab. Can anyone clarify or explain to me php sessions in layman's term? Can anyone also give me codes that use php session in motion. Please i need to finish my code within a month.
A simple example is on the other thread http://forums.digitalpoint.com/showthread.php?t=1130652 That shows the basics of sessions in ten lines.
this is just example <? session_start(); $do=$_GET["do"]; if($_POST) { if($_POST["name"]=='admin' && $_POST["pass"]='pass') { $_SESSION["username"]='Admin'; } } if($do=='logout') { session_destroy(); unset($_SESSION["username"]); } ?> <html> <head> <title>A Sample Login Script | PHPGame.Net</title> </head> <body> <? // ======== IF LOGIN SESSION NOT EXIST-REQUEST TO LOGIN if(!$_SESSION["username"] && $do!='logout') { print " Your are currently not login.<br/>Please login with your username and password below <form action='' method='post'> Username <input type='text' name='name' size='20'/> (admin)<br/> Password <input type='password' name='pass' size='20'/> (pass)<br/> <input type='submit' value= ' Login '/> </form>"; } // ======== LOGOUT if($do=='logout') { print "You have successfully logout.<br/> <a href='index.php'>Click here to main page</a>"; } // ======== LOGIN SESSION EXIST-YOU CAN ONY SEE THIS AREA ONCE YOU LOGIN CORRECTLY if($_SESSION["username"]) { print "Welcome to the Admin area<br/><br/> <a href='?do=logout'>Logout now</a>"; } ?> </body> </html> PHP: