Session in PHP

When you login to your facebook account, your session starts and your session expires as soon as you logout. But sessions can be used in more ways. For example, you are filling out the information form for a job. If you leave half of that form for some time, you will have a message show that your session has expired. If you do not fill the form in a time limit, your session expires and you have to fill the form again.

Now you will be told how to start the session. PHP provides some predefined variables and methods. These are being explained below.

session_start ()
The session_start () function session is used to start. Without this function, you can not start the session.

<?php
session_start();
?>

In the session the variables are created in this way

<?php
session_start();
$ _SESSION ['city'] = "nodia";
?>

After starting the session, if you want to destroy your session, then it uses the php session_destroy () function. This also destroy the session variables with the function session.

<?php
session_destroy();
?>

Example for Set Seesion Value and Get Session Value one page to other page.

sessionset.php

<?php 
session_start();
$_SESSION["city"] = "Noida";
?>

sessionget.php

<?php 
session_start();
echo $_SESSION["city"];
?>

output

Noida

Destroy Session

<?php 
session_start();
if(isset($_SESSION["city"])){
destroy_session();
}
?>
Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.