| setAttribute() | ใช้กำหนด ชื่อ และค่าข้อมูล ให้กับ session |
|---|---|
| getAttribute() | ใช้คืนค่า ค่าข้อมูล ของ Session |
| getAttributeNames() | ใช้คืนค่า ชื่อ ของ Session ทั้งหมด และเก็บไว้ที่ Enumeration |
| removeAttribute() | ใช้ลบ ชื่อ ของ Session ออก |
| setMaxInactiveInterval() | ใช้กำหนด อายุของ Session หน่วยเป็น วินาที |
| getMaxInactiveInterval() | ใช้คืนค่า อายุ ของ Session (ค่า Default คือ 1800) |
| invalidate() | ใช้ทำลาย ค่าต่างๆ ที่ตั้งไว้ใน Session ออกทั้งหมด |
| getId() | ใช้คืนค่า ID ของ Session |
| getCreationTime() | ใช้คืนค่า เวลา ครั้งแรกที่ใช้งาน Session หน่วยมิลลิวินาที |
| getLastAccessedTime() | ใช้คืนค่า เวลา ครั้งสุดท้ายที่ใช้งาน Session หน่วยมิลลิวินาที |
| isNew() | ใช้ตรวจสอบว่า ยังไม่เคยใช้ session ใช่หรือไม่ |
method:setAttribute ( object_string_name, object_string_value );
return type:void
special:static
content:ใช้กำหนด ชื่อ และค่าข้อมูล ให้กับ session
example:session.setAttribute ( “username”, “bamboo” ) ;
method:getAttribute ( object_string_name );
return type:String
special:static
content:ใช้คืนค่า ค่าข้อมูล ของ Session
example:session.setAttribute ( “username”, “bamboo” ) ; session.setAttribute ( “nicknam”, “panda” ) ; String user_name = ( String ) session.getAttribute ( “username” );
method:getAttributeNames ();
return type:Enumeration
special:static
content:ใช้คืนค่า ชื่อ ของ Session ทั้งหมด และเก็บไว้ที่ Enumeration
example:session.setAttribute ( “username”, “bamboo” ) ; session.setAttribute ( “nicknam”, “panda” ) ; Enumeration enum = session.getAttributeNames ();
method:removeAttribute ( object_string_name );
return type:void
special:static
content:ใช้ลบ ชื่อ ของ Session ออก
example:session.setAttribute ( “username”, “bamboo” ) ; session.setAttribute ( “nicknam”, “panda” ) ; session.removeAttribute( “username” );
method:setMaxInactiveInterval ();
return type:void
special:static
content:ใช้กำหนด อายุของ Session หน่วยเป็น วินาที โดยจะเริ่มนับเมื่อไม่ได้ทำอะไรกับ Browser เลย และถ้าไปทำอะไรที่ Browser ก็จะเริ่มนับกันใหม่
example:session.setMaxInactiveInterval( 3600 );
method:getMaxInactiveInterval ();
return type:int
special:static
content:ใช้คืนค่า อายุ ของ Session (ค่า Default คือ 1800)
example:int num = session.getMaxInactiveInterval ();
method:invalidate ();
return type:void
special:static
content:ใช้ทำลาย ค่าต่างๆ ที่ตั้งไว้ใน Session ออกทั้งหมด
example:session.invalidate ();
method:getId ();
return type:String
special:
content:ใช้คืนค่า ID ของ Session
example:String session_id = session.getId ();
method:getCreationTime ();
return type:long
special:static
content:ใช้คืนค่า เวลา ครั้งแรกที่ใช้งาน Session หน่วยมิลลิวินาที โดยเริ่มนับจาก 1 มกราคม ค.ศ.1970 (ตามระบบ GTM)
example:long timestamp = session.getCreationTime ();
method:getLastAccessedTime ();
return type:long
special:static
content:ใช้คืนค่า เวลา ครั้งสุดท้ายที่ใช้งาน Session หน่วยมิลลิวินาที โดยเริ่มนับจาก 1 มกราคม ค.ศ.1970 (ตามระบบ GTM)
example:long timestamp = session.getLastAccessedTime ();
method:isNew ();
return type:boolean
special:static
content:ใช้ตรวจสอบว่า ยังไม่เคยใช้ session ใช่หรือไม่ (true = ใช่) (ถ้าพบคำสั่งนี้หลังคำสั่ง session.invalidate(); ก็จะให้ค่า true ด้วย)
example:if ( ! session.isNew () ) { session.invalidate (); }