| new Cookie() | ใช้สร้างออปเจ็ค และกำหนดชื่อคุ้กกี้ กับค่าของคุ้กกี้ด้วย |
|---|---|
| new Cookie () | ใช้สร้างออปเจ็ค และกำหนดชื่อคุ้กกี้ กับค่าของคุ้กกี้ด้วย |
| setDomain() | ใช้กำหนด ชื่อ Domain ที่สามารถใช้ Cookie นั้นได้ |
| getDomain() | ใช้คืนค่า ชื่อ Domain (ถ้าไม่มีจะคืนค่า null) |
| setPath() | ใช้กำหนด Path ให้ Cookie เพื่อให้ใช้ File และอ่านค่า Cookie ใน Path นั้นๆได้ |
| getPath() | ใช้คืนค่า Path ของ Cookie (ถ้าไม่มีจะคืนค่า null) |
| setMaxAge() | ใช้กำหนด อายุ ของ Cookie มีหน่วยเป็นวินาที |
| getMaxAge() | ใช้คืนค่า อายุ ของ Cookie (ค่า Default คือ -1) |
| setComment() | ใช้กำหนด หมายเหตุ ให้ Cookie |
| getComment() | ใช้คืนค่า หมายเหตุ ของ Cookie (ถ้าไม่ได้กำหนดไว้จะคืนค่า null) |
| setSecure() | ใช้กำหนดว่า จะใช้ความปลอดภัยในการส่ง Cookie หรือไม่ |
| getSecure() | ใช้คืนค่าว่า ได้ใช้ความปลอดภัยในการส่ง Cookie หรือไม่ |
| setValue() | ใช้กำหนด ค่าข้อมูล (Value) ให้ Cookie ใหม่ |
| getValue() | ใช้คืนค่า ค่าข้อมูล (Value) ของ Cookie |
| getName() | ใช้คืนค่า ชื่อ (Name) ของ Cookie |
method:new Cookie ( object_string_name, object_string_value );
return type:Cookie
special:1
content:ใช้สร้างออปเจ็ค และกำหนดชื่อคุ้กกี้ กับค่าของคุ้กกี้ด้วย (ต้องมีการเพิ่มคุ้กกี้เข้าไปในระบบด้วยโดยออปเจ็ค response)
example:Cookie cookie = new Cookie ( “username”, “bamboo” );
method:new Cookie ( “username”, “bamboo” );
return type:Cookie
content:ใช้สร้างออปเจ็ค และกำหนดชื่อคุ้กกี้ กับค่าของคุ้กกี้ด้วย (ต้องมีการเพิ่มคุ้กกี้เข้าไปในระบบด้วยโดยออปเจ็ค response)
example:Cookie cookie = new Cookie ( “username”, “bamboo” );
method:setDomain ( object_string_name );
return type:void
content:ใช้กำหนด ชื่อ Domain ที่สามารถใช้ Cookie นั้นได้
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); cookie.setDomain ( “bamboolabcode” );
method:getDomain ();
return type:String
content:ใช้คืนค่า ชื่อ Domain (ถ้าไม่มีจะคืนค่า null)
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); String domain_name = cookie.getDomain ();
method:setPath ( object_string_url );
return type:void
content:ใช้กำหนด Path ให้ Cookie เพื่อให้ใช้ File และอ่านค่า Cookie ใน Path นั้นๆได้ เพราะโดยปกติ File ที่ใช้ Cookie ได้จะมีเฉพาะ Path ที่สร้าง Cookie รวมถึง Path ย่อย
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); cookie.setPath ( “/” );
method:getPath ();
return type:String
content:ใช้คืนค่า Path ของ Cookie (ถ้าไม่มีจะคืนค่า null)
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); String path = cookie.getPath ();
method:setMaxAge ( int_age );
return type:void
content:ใช้กำหนด อายุ ของ Cookie มีหน่วยเป็นวินาที
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); cookie.setMaxAge ( 6000 );
method:getMaxAge ();
return type:int
content:ใช้คืนค่า อายุ ของ Cookie (ค่า Default คือ -1)
example:Cookie cookie = new Cookie ( “username”, “panda” ); int num = cookie.getMaxAge ();
method:setComment ( object_string_comment );
return type:void
content:ใช้กำหนด หมายเหตุ ให้ Cookie
example:Cookie cookie = new Cookie ( “username”, “panda” ); cookie.setComment ( “หมายเหตุ” );
method:getComment ();
return type:String
content:ใช้คืนค่า หมายเหตุ ของ Cookie (ถ้าไม่ได้กำหนดไว้จะคืนค่า null)
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); String comment = cookie.getComment ();
method:setSecure ( boolean );
return type:void
content:ใช้กำหนดว่า จะใช้ความปลอดภัยในการส่ง Cookie หรือไม่ (true = ใช้) คือจะส่ง Cookie ไปยัง Protocol ที่ปลอดภัยเท่านั้น เช่น HTTPS หรือ SSL
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); cookie.setSecure ( true ) ;
method:getSecure ();
return type:boolean
content:ใช้คืนค่าว่า ได้ใช้ความปลอดภัยในการส่ง Cookie หรือไม่ (true = ใช้)
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); if ( ! cookie.getSecure () ) { cookie.setSecure ( true ); }
method:setValue ( object_string_value );
return type:void
content:ใช้กำหนด ค่าข้อมูล (Value) ให้ Cookie ใหม่
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); cookie.setValue ( “labcode” );
method:getValue ();
return type:String
content:ใช้คืนค่า ค่าข้อมูล (Value) ของ Cookie
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); String str = cookie.getValue ();
method:getName ();
return type:String
content:ใช้คืนค่า ชื่อ (Name) ของ Cookie
example:Cookie cookie = new Cookie ( “username”, “bamboo” ); String name = cookie.getName ();