Hello friends, this is my 13th tutorial of PHP and Today I am sharing the concept of using Sessions in PHP. Sessions are useful for storing and maintaining particular session information. In PHP sessions can be created and maintained very easily. Let us consider a simple example :
 <?php  
//Starting a session
session_start();

//Storing values to session
$_SESSION['first_name']='Santosh';
$_SESSION['last_name']='Tewari';

//Accessing values from session
$fname=$_SESSION['first_name'];
$sname=$_SESSION['last_name'];
echo $fname . " " . $sname;
?>
The session must be started at the very beginning of a php code block. $_SESSION[] is a global array that maintains information about all session objects. You can store and access values from session by using this global array.
Feel free to share your ideas in the comments below.
24 Dec 2014

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.