Posts

Showing posts from September, 2021

PHP-Sessions Login Logout example

Image
   PHP-Sessions Login Logout System       This tutorial explains you How to use session in Login logout module using PHP . To implement this module, we are going to use the following files. session_login.html session_login.php welcome.php logout.php  First create a project folder in server (htdocs/www) and create the files as shown in the below. Next, open the session_login.html in browser and type user : admin and pwd: admin and click login button. Then it is redirected to login.php page, login.php compares the values given in form with the values given in the if condition, if they are similar it stores user value in session and redirected to welcome page. Welcome page( welcome.php) checks user is set or not in session. If yes, then it greets with the message "hello admin you are logged in"  and also displays a link to logout. If you click logout page unsets user value and destroys the session and  redirects to the welcome page. Welcome page again checks if the user is

Session Management in PHP

Image
 Managing Sessions and Using Session Variables       What is  session? Session is the time spent by a single user on a website.  Session can't be shared by any other users. Ex: Login to website.  When a session is created, One unique-id is provided for each user at the time of session start. Ex: sess_07ne2iojd9983gl3ic2a2e06q0  Session can create user specific variables.  These variables are stored at server side. Whereas cookies are stored at client side.  Session-ids available in WAMP/XMPP’s tmp directory. Data available in session accessed by all the pages in a web application.   Creating a Session and Retrieving Session ID session_start() :  Creates a new session and generates a session ID. session_id()     :  Displays session ID. session_create.php   <?php   session_start (); echo session_id ();   ?>   output: sess_07ne2iojd9983gl3ic2a2e06q0   Creating Session Variables and Reading Session Variables:   $_SESSION [ 'user' ]= "John" ; echo "<b