how to store and retrieve array from Session variable using php?

By December 20, 2011 PHP
Here is simple code to illustrate use of session to store array that can be used in other script.
<?php

session_start();

$_SESSION[‘type’] = “ikhlaque”;
$_SESSION[‘colors’] = array(“black”, “silver”, “red”);

if (isset($_SESSION[‘type’]) && isset($_SESSION[‘colors’])) {

echo “You would like a ” , $_SESSION[‘type’] , ” in ” ,
implode(” and “, $_SESSION[‘colors’]);
}
?>
It will output ‘You would like a ikhlaque in black and silver and red’

Leave a Reply

+ 64 = 73

Open chat
💬 Need help?