Friday, July 2, 2010

PHP start session only once to prevent warnings

session_id() returns an empty string if there is no current session, so to test if a session already exists, its better to write this :

if(session_id() == "")
{
session_start();
}
else
{
// Anything you want
}