Session Tracking In Php
Session Tracking In Php :
Session
support in php consists of a way to preserve certain data across subsequent
accesses. This enables you to build more customized applications and increase
the appeal of your website.
A php session variable is used to store
information about , or change settings for a user session.
Session variables hold information about
one single user , and are available to all pages in one application.
A visitor accessing your web application is
assigned a unique id called session id . this is either stored in a cookie on
the client side or is propagated in the url.
Session_start()
: is a builtin function of php used for creating a new
session for a visitor if not exists or to get the reference of the session
which is already existing.
$_SESSION : is a builtin global array of php
which stores the session variable datas of a visitor.
Session_destroy() :
function used to invalidate a session.
Form1.php
<?php
echo "<body
bgcolor=cyan>";
echo "<form
action=form2.php></h1>";
echo "Name
:<input type=text name=t1 size=30><br><br>";
echo "Age :
<input type=text name=t2 size=30><br><br>";
echo "Address :
<input type=text name=t3 size=30><br><br>";
echo "<input
type=submit></form></body>";
?>
Form2.php
<?php
session_start();
$s1 = $_REQUEST['t1'];
$s2 = $_REQUEST['t2'];
$s3 = $_REQUEST['t3'];
$_SESSION['T1']=$s1;
$_SESSION['T2']=$s2;
$_SESSION['T3']=$s3;
/*
setcookie("Name",$s1);
setcookie("Age",$s2);
setcookie("Address",$s3);*/
echo "<body
bgcolor=cyan>";
echo "<form
action=form3.php><h1>";
echo "years of
Exp: <input type=text name=t4 size=30><br><br>";
echo "Language
Known : <input type=text name=t5 size=30><br><br>";
echo "<input
type=submit></form></body>";
?>
Form3.php
<?php
session_start();
$s4 = $_REQUEST['t4'];
$s5 = $_REQUEST['t5'];
$_SESSION['T4']=$s4;
$_SESSION['T5']=$s5;
/*
setcookie("Name",$s1);
setcookie("Age",$s2);
setcookie("Address",$s3);*/
echo "<body
bgcolor=cyan>";
echo "<form
action=form4.php><h1>";
echo "Exp
Salary:<input type=text name=t6 size=30><br><br>";
echo "<input
type=submit></form></body>";
?>
Form4.php
<?php
session_start();
echo "<body
bgcolor=pink><h1>";
foreach ($_SESSION as
$key=>$val)
{
echo
$key."--".$val."<br>";
}
/*
foreach ($_COOKIE as
key=>$val)
{
echo $key."--".$val."<br>";
}*/
echo
"T6--".$_REQUEST['t6']."<br><br>";
echo session_id();
?>
Output:
T1--ryt
T2--32432
T3--sesd
T4--34
T5--sddsf
T6--2432
6lcr6eg7ghsac93ddugvhnfe05
This comment has been removed by the author.
ReplyDeleteNice Article
ReplyDeleteJust I World
hahahaha very goooood
ReplyDeletemysql services
awesome article.visit us
ReplyDeletehttps://youtu.be/_gjJvp3wPEo
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNot helpful
ReplyDeletephp examples for webmasters
ReplyDeleteShow result with paging and staging
Click to see the code!
To insert emoticon you must added at least one space before the code.