PHP

Topic: Sessions

How To Retrieve Values from the Current Session?

If you know some values have been saved in the session by an other script requested by the same visitor, you can retrieve those values back by using the pre-defined associative array called $_SESSION. The following PHP script shows you how to retrieve values from the session:<?php  session_start();  print("<html><pre>");  $myLogin = $_SESSION["MyLogin"];  print("Value of MyLogin has been retrieved: ".$myLogin."\n");  $myColor = $_SESSION["MyColor"];  print("Value of MyColor has been retrieved: ".$myColor."\n");  print("</pre></html>\n");?>You need to save this script to your Web server as next_page.php. Now visit first_page.php and click the "Next Page" hyper like, you will get:Value of MyLogin has been retrieved: FYICenterValue of MyColor has been retrieved: Blue

Browse random answers: