日期:2014-05-16 浏览次数:20523 次
<%@ page contentType="text/html; charset=utf-8" %> <% response.addHeader("Cache-Control", "no-cache"); response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); String ssocookie="www.sso12345678910.com"; %> <script src="http://www.a.com/mp/test/a_setcookie.jsp?id=<%=ssocookie%>"> </script>
<% response.setHeader("P3P","CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""); String domainId=request.getParameter("id"); Cookie _cookie=new Cookie("test",domainId); _cookie.setMaxAge(30*60*100); _cookie.setPath("/"); response.addCookie(_cookie); %>
<%@ page contentType="text/html; charset=utf-8" %> <% Cookie cookies[]=request.getCookies(); // 将适用目录下所有Cookie读入并存入cookies数组中 Cookie sCookie=null; String sname=null; String name=null; if(cookies==null) // 如果没有任何cookie out.print("none any cookie"); else { out.print(cookies.length + "<br>"); for(int i=0;i<cookies.length; i++) // 循环列出所有可用的Cookie { sCookie=cookies[i]; sname=sCookie.getName(); name = sCookie.getValue(); out.println("comment==>>>"+sCookie.getComment()+"\n"); out.println("getDomain==>>>"+sCookie.getDomain()+"\n"); out.println("getSecure==>>"+sCookie.getSecure()+"\n"); out.println("getVersion==>>"+sCookie.getVersion()+"\n"); out.println("cookiename==>>"+sname + "->" + "cookievalue==>>>"+name + "<br>"); } } %>