天天看點

清除session,cookie

1.?[浠g??][Java]浠g???????

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

????

?

1

. [浠g??]涓???娓??ら〉?㈢?瀛? ??sp椤甸?????

01

?

//??sp椤甸??

02

?

<%

03

?

response.setHeader(

"Pragma"

,

"No-cache"

);

04

?

response.setHeader(

"Cache-Control"

,

"no-cache"

);

05

?

response.setDateHeader(

"Expires"

,

);

06

?

response.flushBuffer();

07

?

%>

08

?

//??tml椤甸??

09

?

<meta http-equiv=

"Content-Type"

content=

"text/html; charset=gb2312"

>

10

?

<META HTTP-EQUIV=

"Pragma"

CONTENT=

"no-cache"

>

11

?

<META HTTP-EQUIV=

"Cache-Control"

CONTENT=

"no-cache"

>

12

?

<META HTTP-EQUIV=

"Expires"

CONTENT=

"0"

>

2

. [浠g??]浜???娓???ookie???

1

??

<%?

2

????????????

Cookie?? killMyCookie?? =??

new

??

Cookie(

"mycookie"

,??

null

);?

3

????????????

killMyCookie.setMaxAge(

);?

4

????????????

killMyCookie.setPath(

"/"

);?

5

????????????

response.addCookie(killMyCookie);?

6

??

%>

3

. [浠g??]涓???娓???ession???? 璺寵??[

1

] [

2

] [

3

] [?ㄥ?棰?瑙?]

view source

print?

1

??

<%@ page language=

"java"

session=

"false"

%>?

2

??

<%?

3

????

session.invalidate();?

4

??

%>

5

??

//?ㄩ〉?㈠?抽???舵???ession锛???瑕?????indows.onclose浜?浠訛???璋??ㄦ???ession?規?