How to find out if you have started a session
The function session_id will return the string id of the current session, or if there is no session it will return an empty string, so the following can detect if you currently have a session active.
if (empty(session_id())
{
echo "You have no session";
}
If you start a session twice you can get a notice saying that a session has already started, so to get around this you
can do something like...
{
echo "You have no session";
}
if (empty(session_id())
{
start_session();
}
{
start_session();
}
Comments
Post a Comment