Storing Simple Data Types in Sessions : Session Variables « Cookie Session « PHP






Storing Simple Data Types in Sessions

 
<?php
  session_start();
  
  (int) $_SESSION['integer_value'] = "115";
  (string) $_SESSION['string_value'] = "Hello World";
  (float) $_SESSION['float_value'] = "1.07";
  
  function outputsessions (){
    echo $_SESSION['integer_value'] . "<br />"; 
    echo $_SESSION['string_value'] . "<br />"; 
    echo $_SESSION['float_value'] . "<br />"; 
  }
  outputsessions();
?>
  
  








Related examples in the same category

1.A session variable can be destroyed with a call to session_unregister().
2.Accessing Session Variables
3.Adding Session Data
4.Checking Session Data
5.Reading Session Data
6.Registering Variables with a Session
7.Registering an Array Variable with a Session
8.Storing Complex Data Types in Sessions
9.Storing Complex Data Types to session