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 :
Feel free to share your ideas in the comments below.
<?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.
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.