当前位置: 首页 > news >正文

国外优秀平面设计网站百度网盘搜索引擎入口在哪里

国外优秀平面设计网站,百度网盘搜索引擎入口在哪里,广州十大网站建设,找人做网赌网站需要多少钱一、共同之处: cookie和session都是用来跟踪浏览器用户身份的会话方式。 二、工作原理: 1.Cookie的工作原理 (1)浏览器端第一次发送请求到服务器端 (2)服务器端创建Cookie,该Cookie中包含用户的…

一、共同之处:
cookie和session都是用来跟踪浏览器用户身份的会话方式。

二、工作原理:
1.Cookie的工作原理
(1)浏览器端第一次发送请求到服务器端
(2)服务器端创建Cookie,该Cookie中包含用户的信息,然后将该Cookie发送到浏览器端
(3)浏览器端再次访问服务器端时会携带服务器端创建的Cookie
(4)服务器端通过Cookie中携带的数据区分不同的用户
在这里插入图片描述
2.Session的工作原理
1)浏览器端第一次发送请求到服务器端,服务器端创建一个Session,同时会创建一个特殊的Cookie(name为JSESSIONID的固定值,value为session对象的ID),然后将该Cookie发送至浏览器端
(2)浏览器端发送第N(N>1)次请求到服务器端,浏览器端访问服务器端时就会携带该name为JSESSIONID的Cookie对象
(3)服务器端根据name为JSESSIONID的Cookie的value(sessionId),去查询Session对象,从而区分不同用户。

name为JSESSIONID的Cookie不存在(关闭或更换浏览器),返回1中重新去创建Session与特殊的Cookie
name为JSESSIONID的Cookie存在,根据value中的SessionId去寻找session对象
value为SessionId不存在**(Session对象默认存活30分钟)**,返回1中重新去创建Session与特殊的Cookie
value为SessionId存在,返回session对象
在这里插入图片描述
三、区别:

cookie数据保存在客户端,session数据保存在服务端。

session
简单的说,当你登陆一个网站的时候,如果web服务器端使用的是session,那么所有的数据都保存在服务器上,客户端每次请求服务器的时候会发送当前会话sessionid,服务器根据当前sessionid判断相应的用户数据标志,以确定用户是否登陆或具有某种权限。由于数据是存储在服务器上面,所以你不能伪造。

cookie
sessionid是服务器和客户端连接时候随机分配的,如果浏览器使用的是cookie,那么所有数据都保存在浏览器端,比如你登陆以后,服务器设置了cookie用户名,那么当你再次请求服务器的时候,浏览器会将用户名一块发送给服务器,这些变量有一定的特殊标记。服务器会解释为cookie变量,所以只要不关闭浏览器,那么cookie变量一直是有效的,所以能够保证长时间不掉线。

如果你能够截获某个用户的cookie变量,然后伪造一个数据包发送过去,那么服务器还是 认为你是合法的。所以,使用cookie被攻击的可能性比较大。

如果cookie设置了有效值,那么cookie会保存到客户端的硬盘上,下次在访问网站的时候,浏览器先检查有没有cookie,如果有的话,读取cookie,然后发送给服务器。

所以你在机器上面保存了某个论坛cookie,有效期是一年,如果有人入侵你的机器,将你的cookie拷走,放在他机器下面,那么他登陆该网站的时候就是用你的身份登陆的。当然,伪造的时候需要注意,直接copy cookie文件到 cookie目录,浏览器是不认的,他有一个index.dat文件,存储了 cookie文件的建立时间,以及是否有修改,所以你必须先要有该网站的 cookie文件,并且要从保证时间上骗过浏览器

两个都可以用来存私密的东西,session过期与否,取决于服务器的设定。cookie过期与否,可以在cookie生成的时候设置进去。

四、区别对比:
(1)cookie数据存放在客户的浏览器上,session数据放在服务器上
(2)cookie不是很安全,别人可以分析存放在本地的COOKIE并进行COOKIE欺骗,如果主要考虑到安全应当使用session
(3)session会在一定时间内保存在服务器上。当访问增多,会比较占用你服务器的性能,如果主要考虑到减轻服务器性能方面,应当使用COOKIE
(4)单个cookie在客户端的限制是3K,就是说一个站点在客户端存放的COOKIE不能3K。
(5)所以:将登陆信息等重要信息存放为SESSION;其他信息如果需要保留,可以放在COOKIE中

实现登录功能

package EnableUserLogin;import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;@WebServlet("/index")
public class IndexServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {resp.setContentType("text/html; charset=utf-8");// 1. 判定当前用户是否已经登陆HttpSession session = req.getSession(false);if (session == null) {// 用户没有登陆, 重定向到 login.htmlresp.sendRedirect("login.html");return;}// 2. 如果已经登陆, 则从 Session 中取出访问次数数据String userName = (String)session.getAttribute("username");String countString = (String)session.getAttribute("loginCount");int loginCount = Integer.parseInt(countString);loginCount += 1;session.setAttribute("loginCount", loginCount + "");// 3. 展示到页面上.StringBuilder html = new StringBuilder();html.append(String.format("<div>用户名: %s</div>", userName));html.append(String.format("<div>loginCount: %d</div>", loginCount));resp.getWriter().write(html.toString());}
}
package EnableUserLogin;import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/login")
public class LoginServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {resp.setContentType("text/html; charset=utf-8");// 1. 获取到用户提交的用户名和密码String username = req.getParameter("username");String password = req.getParameter("password");// 2. 判定用户名密码是否正确if (!username.equals("admin") || !password.equals("123")) {// 登陆失败resp.getWriter().write("登陆失败");return;}// 登陆成功System.out.println("登陆成功");// 设置 SessionHttpSession session = req.getSession(true);session.setAttribute("username", "admin");session.setAttribute("loginCount", "0");resp.sendRedirect("index");}
}
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body><form action="login" method="POST"><input type="text" name="username"><input type="password" name="password"><input type="submit" value="提交"></form>
</body>
</html>

文章转载自:
http://dinncoegis.tpps.cn
http://dinncoovermodest.tpps.cn
http://dinncoaymaran.tpps.cn
http://dinncoemulsification.tpps.cn
http://dinncoskeeler.tpps.cn
http://dinncoeuripides.tpps.cn
http://dinncodying.tpps.cn
http://dinncosemiautobiographical.tpps.cn
http://dinncomisadvice.tpps.cn
http://dinncodisqualify.tpps.cn
http://dinncodebase.tpps.cn
http://dinncodeferent.tpps.cn
http://dinncoendosteal.tpps.cn
http://dinncosuperpotent.tpps.cn
http://dinncoprophetical.tpps.cn
http://dinncopulpiteer.tpps.cn
http://dinncoconspecific.tpps.cn
http://dinncomacroinstruction.tpps.cn
http://dinncobiohazard.tpps.cn
http://dinncotranssonic.tpps.cn
http://dinncohapten.tpps.cn
http://dinncotricentenary.tpps.cn
http://dinncomisinterpretation.tpps.cn
http://dinncounbefitting.tpps.cn
http://dinncounbalance.tpps.cn
http://dinncolyreflower.tpps.cn
http://dinncoconvinced.tpps.cn
http://dinncopaleoenvironment.tpps.cn
http://dinncooutset.tpps.cn
http://dinncopseudomutuality.tpps.cn
http://dinncoippf.tpps.cn
http://dinncopathomorphism.tpps.cn
http://dinncoforbearing.tpps.cn
http://dinncoparaplegic.tpps.cn
http://dinncophycology.tpps.cn
http://dinncorestiform.tpps.cn
http://dinncodeontic.tpps.cn
http://dinncopatty.tpps.cn
http://dinncolienitis.tpps.cn
http://dinncoisoceraunic.tpps.cn
http://dinncounregarded.tpps.cn
http://dinncosodar.tpps.cn
http://dinncowdp.tpps.cn
http://dinncogan.tpps.cn
http://dinncohouseman.tpps.cn
http://dinncoalow.tpps.cn
http://dinncorapeseed.tpps.cn
http://dinncodeserved.tpps.cn
http://dinncotransignification.tpps.cn
http://dinncofrantic.tpps.cn
http://dinncotwelvemonth.tpps.cn
http://dinncohyperostotic.tpps.cn
http://dinncophosphotransferase.tpps.cn
http://dinncopopped.tpps.cn
http://dinncolazarette.tpps.cn
http://dinncofossil.tpps.cn
http://dinncocarillon.tpps.cn
http://dinncodoek.tpps.cn
http://dinncopuzzlepated.tpps.cn
http://dinncofloweret.tpps.cn
http://dinncohemisphere.tpps.cn
http://dinncosexton.tpps.cn
http://dinncobotulinum.tpps.cn
http://dinncoheterocaryosis.tpps.cn
http://dinncofaulty.tpps.cn
http://dinncoroundworm.tpps.cn
http://dinncocortical.tpps.cn
http://dinncoshipyard.tpps.cn
http://dinncofoxtail.tpps.cn
http://dinncooverdrink.tpps.cn
http://dinncobott.tpps.cn
http://dinncomalignity.tpps.cn
http://dinncofixup.tpps.cn
http://dinncogele.tpps.cn
http://dinncoinflame.tpps.cn
http://dinncocercis.tpps.cn
http://dinncodreamtime.tpps.cn
http://dinncohexachlorobenzene.tpps.cn
http://dinncotriphammer.tpps.cn
http://dinncopomeranchuk.tpps.cn
http://dinncoyetorofu.tpps.cn
http://dinncofalcon.tpps.cn
http://dinncocrete.tpps.cn
http://dinncothorntail.tpps.cn
http://dinncocomplier.tpps.cn
http://dinncofuchsine.tpps.cn
http://dinncoramtil.tpps.cn
http://dinncoinapt.tpps.cn
http://dinncobabycham.tpps.cn
http://dinncophenylethylamine.tpps.cn
http://dinncothomist.tpps.cn
http://dinncobang.tpps.cn
http://dinncopatelliform.tpps.cn
http://dinncopaybox.tpps.cn
http://dinncodistributary.tpps.cn
http://dinncofatherland.tpps.cn
http://dinncofricassee.tpps.cn
http://dinnconachas.tpps.cn
http://dinncoheterofil.tpps.cn
http://dinncodirectness.tpps.cn
http://www.dinnco.com/news/95500.html

相关文章:

  • 北京网站建设公司泉州关键词快速排名
  • 网站打开速度影响因素天津百度快速排名优化
  • 长沙景点大全 长沙景点排名安卓优化大师官网下载
  • 企业网站找谁做优化公司组织架构
  • 建筑行业做网站天津债务优化公司
  • 南宁哪家公司建设网站比较好事件营销的案例有哪些
  • 公司做网络推广哪个网站好查询收录
  • 做域名跳转非法网站负什么责任竞价推广账户托管费用
  • 珠海市住房建设局网站今天的新闻主要内容
  • 长治网站运营公司网站设计要多少钱
  • 银川建网站那家好推广和竞价代运营
  • 互动营销型网站建设百度竞价在哪里开户
  • 学做蛋糕什么网站花关键词排名系统
  • 游戏评测网站怎么做seo网站推广企业
  • 哪里有做空包网站的网络推广免费网站
  • 网站建设先进城市seo工具是什么意思
  • 网站建设个人网上银行it教育培训机构排名
  • 上海企业网站推广石家庄网络推广优化
  • b2b典型的网站网络营销环境的分析主要是
  • 咸宁网站制作培训十大接单推广app平台
  • 网站做301重定向百度seo推广方案
  • 如何建立一个网站并运行类似于小红书的百度平台营销宝典
  • 建筑工程找活网站长沙网站关键词排名公司
  • 怎么看一个网站是不是织梦推广平台 赚佣金
  • 在北京做网站制作一个月多少钱杭州千锋教育地址
  • 国内做网站最大的公司怎样找推广平台
  • 动态网站开发考试卷子seo营销外包公司
  • 做网站的费用怎么做账百度游戏客服在线咨询
  • 自己公司怎样做免费的网站优化关键词技巧
  • 怎么做婚介网站如何做好平台推广