| instance() | ใช้สร้าง object ของ Library Session |
|---|---|
| create() | ใช้สร้าง object ของ Library Session ใหม่ ( คือมันจะทำลายค่าเก่าทั้งหมด ) |
| destroy() | ใช้ทำลายค่าเก่าของ Session ทั้งหมด |
| id() | ใช้คืนค่า session id |
| regenerate() | ใช้ generate session ใหม่ และคืนค่า session id นั้นกลับมา |
| get() | ใช้คืนค่า value ของ name ที่กำหนด |
| get_once() | ใช้คืนค่า value ของ name ที่กำหนด และจะทำลาย session ของ name นั้นทิ้งทันที |
| set() | ใช้กำหนดค่า ให้กับ session |
| set ( array_data ) | ใช้กำหนดค่า ให้กับ session แบบ array |
| delete() | ใช้ลบ name ออกจาก session ที่กำหนด |
method:instance ();
return type:Object
special:static
content:ใช้สร้าง object ของ Library Session
example:$session = Session::instance ();
method:create ();
return type:void
content:ใช้สร้าง object ของ Library Session ใหม่ ( คือมันจะทำลายค่าเก่าทั้งหมด )
example:$session = Session::instance (); $session->set ( "user", "bamboo" ); $session->create ();
method:destroy ();
return type:void
content:ใช้ทำลายค่าเก่าของ Session ทั้งหมด
example:$session = Session::instance (); $session->set ( "user", "bamboo" ); $session->destroy ();
method:id ();
return type:string
content:ใช้คืนค่า session id
example:$session = Session::instance (); echo $session->id ();
method:regenerate ();
return type:string
content:ใช้ generate session ใหม่ และคืนค่า session id นั้นกลับมา
example:$session = Session::instance (); echo $session->id (); echo $session->regenerate ();
method:get ( name, default_value );
return type:string
content:ใช้คืนค่า value ของ name ที่กำหนด โดยจะคืนค่า default_value กลับมา ในกรณีที่ name นั้น ไม่มีอยู่จริงใน session
example:$session = Session::instance (); echo $session->get ( "user", "admin" );
method:get_once ( name );
return type:string
content:ใช้คืนค่า value ของ name ที่กำหนด และจะทำลาย session ของ name นั้นทิ้งทันที
example:$session = Session::instance (); $session->set ( "user", "bamboo" ); echo $session->get_once ( "user" );
method:set ( name, value );
return type:void
content:ใช้กำหนดค่า ให้กับ session
example:$session = Session::instance (); $session->set ( "user", "bamboo" );
method:set ( array_data );
return type:void
content:ใช้กำหนดค่า ให้กับ session แบบ array
example:$authen["user"] = "bamboo"; $authen["pass"] = "labcode"; $session = Session::instance (); $session->set ( $authen );
comment:ตัวแปร array_data มี key คือ name และ value คือค่าข้อมูล
method:delete ( name_1, name_2, ..., name_3 );
return type:void
content:ใช้ลบ name ออกจาก session ที่กำหนด
example:$authen["user"] = "bamboo"; $authen["pass"] = "labcode"; $session = Session::instance (); $session->set ( $authen ); $session->delete ( "user" );