利用HttpResponse的addHeader方法,設定Set-Cookie的值
cookie字串的格式:key=value; Expires=date; Path=path; Domain=domain; Secure; HttpOnly
//設定cookie
response.addHeader("Set-Cookie", "uid=112; Path=/; HttpOnly");
//設定多個cookie
response.addHeader("Set-Cookie", "timeout=30; Path=/test; HttpOnly");
//設定https的cookie
response.addHeader("Set-Cookie", "uid=112; Path=/; Secure; HttpOnly");
在實際使用中,我們可以使FireCookie檢視我們設定的Cookie 是否是HttpOnly
利用HttpResponse的addHeader方法,設定Set-Cookie的值
cookie字串的格式:key=value; Expires=date; Path=path; Domain=domain; Secure; HttpOnly
//設定cookie
response.addHeader("Set-Cookie", "uid=112; Path=/; HttpOnly");
//設定多個cookie
response.addHeader("Set-Cookie", "uid=112; Path=/; HttpOnly");
response.addHeader("Set-Cookie", "timeout=30; Path=/test; HttpOnly");
//設定https的cookie
response.addHeader("Set-Cookie", "uid=112; Path=/; Secure; HttpOnly");
在實際使用中,我們可以使FireCookie檢視我們設定的Cookie 是否是HttpOnly