게시판 게시판 프로젝트를 만들고 있습니다. 여기에서 session
을 관리하기 위해 Session class
을 생성합니다.어디에서 프로젝트에 새 Session을 넣어야합니까?
내 index.php
$bulletin = new Controller_Bulletin();
$bulletin->setParams(array_merge($_GET, $_POST));
$bulletin->execute('index'); // Execute index action
내 Controller_Bulletin.php
class Controller_Bulletin extends Controller_Base
{
...
public function index() // My index action
{
// Render the index html
$this->render('bulletin/index.php', get_defined_vars());
}
public function insert() // My insert action
{
...
}
...
}
내 나는 모든 행동에서 세션 클래스를로드 할 필요 Session class
class Session
{
public function __construct()
{
session_start();
}
...
}
. 예 : 색인, 삽입 등 하지만 모든 작업에 $session = new Session();
을 넣었을 때. 제 멘토는 좋지 않다고했습니다. 어쩌면 나는 모든 행동에 그것을 복제했기 때문에. 나는 아직도 OOP 좋은 아니에요 Controller_Bulletin class
public function index()
{
$session = new Session();
...
}
public function insert()
{
$session = new Session();
...
}
에 예. 누군가 세션 객체를 어디에서 불러야하나요? 아직도 내 질문이 명확하지 않으면 알려주세요.
나는 이미 그렇게 생각합니다. 아마도 시도해 보겠습니다. 나중에 멘토 질문을 업데이트하겠습니다. – Scramble