To create a session use the function :
session_start();
To put some info in the session first declare a variable containing the info
i.e. $variable = "test";
Then register the variable to the session using
session_register()
i.e. session_register("variable");
To erase the data in a session use the function session_unregister().
i.e. session_unregister("variable");
In my knowledge there is no specific function to check if a session is running what you could do is :
session_start(); //start the session
$running = "1"; // create a variable saying the session is running
session_register("running"); // registering the variable to the session so that you can check on other pages if the session is running.
// Few lines later, when you want to check if the session exists : //
if($running=="1"){
// do that
}else{
// do this
}
By "reading" a session I'll suppose you mean how to access the variables saved in a session.
First start the session ( session_start() ), you must do this on every page where you do session manipulations. Then use the variable in the session variables as normal variables.
i.e. echo $variable; // that will print "test" on the screen
To summarize it all :
// start the session
session_start();
$running = 1;
session_register("running");
// make a few variable
$variable1 = "blah";
$variable2 = "test";
// register them to the session
session_register("variable1");
session_register("variable2");
// check if the function is started
if($running){
// print out the variables
echo $variable1 . "<br>" . $variable2;
}else{
echo "The session isn't working"
}
}
Hope that will help you.
For more information on sessions : http://www.php.net/manual/en/ref.session.php