ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

How to Retrieve Data from Session Array Variable in PHP

session array variable
In this tutorial, I will teach you how to retrieve data from a session array variable in php. Retrieving data from session array is just very easy to do. With the use of Foreach Loop, every data that you have stored in a session variable will appear in order.

Let’s begin :

First, start a session for reading the session handler.

Second,declare a session array variable and store any value in it.

  1. //It represents the employee basic information.
  2.  $_SESSION['employee'] = array("Firstname"=>"Janobe", "Lastname"=>"Palacios", "Address"=>"Kabankalan", "Email"=>"jannopalacios@gmail.com");

Third, fetch the data from a session array variable using foreach loop.

  1. foreach ($_SESSION['employee'] as $key =>  $value) {
  2.     # code...
  3. echo $key .' :'.$value .'<br />';
  4.  
  5. }

Output :

Firstname :Janobe
Lastname :Palacios
Address :Kabankalan
Email :jannopalacios@gmail.com

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!