A session is basically a temporary set of variables used to transfer information from one page to another. More broadly we can say that it gives options to create once and used inside whole project. Through session we can manage general information inside a Web application. The best example of Session usage is in login/logout inside a web Application. That’s why we can say that Session is known as the Heart of Web Application. This information is stored temporarily for your PHP programs to refer back to whenever needed. Every session is assigned a unique session ID, which keeps all the current information together.
By default it is stored physically inside “tmp” directory in our Web server. Like session.save_path = “d:/wamp/tmp”. OR session.save_path = “c:/wamp/tmp”, depend on your installation drive. The default directory can be change via session.save_path setting inside php.ini. The directory which we will replace should be physically available inside our Web Hosting account.
The longivity of a session depend on either shut down of the specific browser where it is currently being used OR It’s longevity defined inside php.in setting like session.gc_maxlifetime = 1440. (1440 seconds or 24 minutes).
Some basic Session related functions in PHP
session_start() — Start Session.
$_SESSION[‘username’] = $_POST[‘user_name’] OR
$_SESSION[‘username’] = $_GET[‘user_name’] OR
$_SESSION[‘username’] = ‘Constant_name’;
echo $_SESSION[‘username’]; //Echo Session variable
session_destroy() — Destroys all data registered to a session
session_unset(); — Free all session variables
unset($_SESSION[‘name’]); — To remove a specific variable from the session.
We can extend the longevity of a session by using cookie also.
This setting is determined in your php.ini file. If you would like to force the user to pass variables through cookies (instead of allowing a backup plan), you would set the following line in your file:
session.use_only_cookies = 1
php courses in ranchi jharkhand,php courses in ranchi jharkhand, php training in ranchi jharkhand, Php training institute, PHP Training institute in Ranchi Jharkhand,