Switch to full style
Dynamic open source server-side web development
Post a reply

PHP session variables

Thu Jul 30, 2009 9:31 am

Print PHP session variables
Here is the flow :

Code:
index.php->page1.php->page2.php->page3.php


Here are the excerpts from the files.

index.php :
Code:

session_start
();
session_register("username_session");
session_register("fullname_session");
$_SESSION["username_session"]=<value from database>
$_SESSION["fullname_session"]=<value from database> 


page1.php :


Nothing related to session or session variables in this page. Just pass on a few form fields to next page.
The form fields are "firstvar" and "secondvar"

page2.php :
Code:

session_start
();
session_register("firstvar_session");
session_register("secondvar_session");

$_SESSION["firstvar_session"]=$_POST["firstvar"]
$_SESSION["secondvar_session"]=$_POST["secondar"]

 

page3.php:

I access session variables here
Code:

session_start
();
echo "username=".$_SESSION["username_session"]."<BR>";
echo "fullname=".$_SESSION["fullname_session"]."<BR>";
echo "firstvar=".$_SESSION["firstvar_session"]."<BR>";
echo "secondvar=".$_SESSION["secondvar_session"]."<BR>";

 


Here is the output :
Code:
username=ganesh
fullname=M. Ganesh
firstvar=
secondvar=




Post a reply
  Related Posts  to : PHP session variables
 Modify Session Variables     -  
 PHP session variables problem in Firefox     -  
 Local variables vs Instance variables     -  
 session in jsp     -  
 PHP Variables     -  
 Casting Variables in php     -  
 Scope Variables in php     -  
 php login with session     -  
 Apache Variables in php     -  
 EJB session bean     -  

Topic Tags

PHP Sessions