Rozamunda
asked on
session_start in PHP class file
Do I need session_start in the beginning of a class file in PHP to use $_SESSION ?
You need it at the top of the page that the class is on
ASKER
so that means if i have a program:
<?
session_start();
require_once myclass.php
?>
i need to have also session_start
in myclass.php, if i refer there to a session ?. Yes ?
<?
session_start();
require_once myclass.php
?>
i need to have also session_start
in myclass.php, if i refer there to a session ?. Yes ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION)) {
session_start();
}
You need not start the session on every page, it can be included once in any include file .. so that it would be referred all the pages.. (included)