How to use PHP session?

  • yagas
  • Novice
  • Novice
  • User avatar
  • Posts: 25
  • Loc: China

Post 3+ Months Ago

How to use PHP session?
I use is asp.
now use to php.
but,I don't use php session.
help me!
:(
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

basic example:

to set variables:
PHP Code: [ Select ]
 
session_start();
 
$_SESSION['variableName'] = "some value";
 
$_SESSION['variableName2'] = "another value";
 
session_write_close();
 
 
  1.  
  2. session_start();
  3.  
  4. $_SESSION['variableName'] = "some value";
  5.  
  6. $_SESSION['variableName2'] = "another value";
  7.  
  8. session_write_close();
  9.  
  10.  


to retrieve session variables
PHP Code: [ Select ]
 
session_start();
 
$gimmeVar1 = $_SESSION['variableName1'];
 
$gimmeVar2 = $_SESSION['variableName2'];
 
session_write_close();
 
 
  1.  
  2. session_start();
  3.  
  4. $gimmeVar1 = $_SESSION['variableName1'];
  5.  
  6. $gimmeVar2 = $_SESSION['variableName2'];
  7.  
  8. session_write_close();
  9.  
  10.  


Pretty simple actually. If you are working with session variables just make sure you have the session_start call

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 120 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.