Tuesday, February 6, 2018

PHP SESSIONS

                                               PHP SESSIONS

        A session variable is used to store the information about or change the settings for a user session.
Session variables hold information about one single user and are all variables to all pages in one application.

     When the user working with applications, the user wants to open it and make the changes and the user want to close it.The session is also a server side temporary memory storage.

      The web browser is don't know who is the user and the what the user can do because the HTTP
Protocol has not maintained the state.

Session start:


     The maximum lifetime of the session is 1440 seconds.We can able to change the time using

                         ini_set('session.gc_maxlifetime', 3600) 


Example:

<?php
session_start();
?>
<html>
<body>
<?php
$_SESSION["favcricketer"]= "Tendulkar";
$_SESSION["favcar"]= "BMW";
echo "Session variables are set."
?>
</body>

</html>

Output:

Session variables are set.

Note:
        In this seeion_start() is used to start the session in PHP Programming world.

Session Destroy:

Example:

       If the user wants to delete the session users want to use session_destroy()

 <?php
session_start();
?>
<html>
<body>
<?php
session_destroy();
echo "All sessions are deleted."
?>
</body>
</html>

Output:
        
     All sessions are deleted.

No comments:

Post a Comment

A R Murugadoss --- Film Career and Biography

         A R Murugadoss --- Film Career a Biography  Early Life :          A.R Murugadoss was Born on 25th September in the Year o...