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

施工企业价值链seo怎么才能优化好

施工企业价值链,seo怎么才能优化好,天元建设集团有限公司总裁赵纪峰,无锡电子商务网站建设cookie和session 发展史 一开始,只有一个页面,没有登录功能,大家看到东西都一样。 时代发展,出现了需要登录注册的网站,要有一门技术存储我们的登录信息,于是cookie诞生了。 cookie: - 存储形式:k:v键值对…

cookie和session

发展史

        一开始,只有一个页面,没有登录功能,大家看到东西都一样。

        时代发展,出现了需要登录注册的网站,要有一门技术存储我们的登录信息,于是cookie诞生了。

        cookie:

- 存储形式:k:v键值对

- 存储位置:客户端

- 不安全,信息可能会泄露

        时代再度发展,需要有一门新的安全的技术,于是有了session。

        session:

- 标识符,来表示我是当前用户加密出来的数据

- 对敏感信息进行加密处理

        - 存储服务端    

        - 标识符配合上你的加密串

- 把我的标识符+ 字符串全给客户端

        - 客户端存储格式    

        - session_id:返回回来的表示符+加密串

django操作cookies

        设置cookie
def login(request, *args, **kwargs):if request.method == 'POST':username = request.POST.get("username")password = request.POST.get("password")if username == "kevin" and password == "123":obj = HttpResponse("ok")obj.set_cookie('sign', 'user')return objelse:return redirect('/login/')return render(request, 'login.html')
        取值cookie验证
def home(request, *args, **kwargs):sign = request.COOKIES.get('sign')if sign and sign == 'user':return HttpResponse("这是home页面")else:return redirect('/login/')
        设置过期时间
obj.set_cookie('sign', 'user', expires=3)
obj.set_cookie('sign', 'user', max_age=3)
        删除cookie
def logout(request, *args, **kwargs):obj = redirect('/home/')# 设置超时时间 5s 到期obj.delete_cookie('sign')return obj

django操作session

        设置session
request.session['sign'] = 'user'
        取值session
def login(request, *args, **kwargs):# next_url = request.get_full_path()# print(next_url) # /login/?next_url=/home/if request.method == 'POST':username = request.POST.get("username")password = request.POST.get("password")if username == "dream" and password == "521":# next_url = request.GET.get('next_url')# print(next_url) # /home/request.session['sign'] = 'user'obj = redirect('/home/')# 设置过期时间# obj.set_cookie('sign', 'user', expires=3)# obj.set_cookie('sign', 'user', max_age=3)return objelse:return redirect('/login/')return render(request, 'login.html')
​
​
def login_auth(func):def inner(request, *args, **kwargs):# print(request.path_info) #  /home/# print(request.get_full_path()) # /home/?username=111next_url = request.get_full_path()  # /home/# print(next_url)# /home/sign = request.session.get('sign')# print(sign) # userif sign and sign == 'user':res = func(request, *args, **kwargs)return reselse:return redirect(f'/login/?next_url={next_url}')
​return inner
​
​
@login_auth
def home(request, *args, **kwargs):return HttpResponse("这是home页面")

        注:

- session基于数据库表才能使用的  - 必须先迁移数据库,生成 django_session 表

- session只对当次登录有效  

- 主动清除浏览器中本地存在的session  

- 验签发现,没有sessionid就会自动生成新的session

- `django_sessoin`表中的数据条数取决于浏览器

- 同一个计算机(IP地址)上同一个浏览器只会有一条数据生效

- 同一个计算机(IP地址)上多个浏览器会有多个数据生效

- 当session过期的时候,可能会出现多条数据对应一个浏览器

- 但是这些数据不会持久化存储,会被定时清理掉,可以手动清除也可以代码清除

- 目的是为了节省服务器数据库资源

        设置session过期时间
request.session['sign'] = 'user'
request.session.set_expiry(0)
        删除cookie
# 删除session
request.session.delete()
# 把浏览器和数据库里面的session全部清除掉
request.session.flush()

CBV加装饰器的三种方法

from django.utils.decorators import method_decorator
​
# 方式二:放在类视图上面 (放的装饰器函数,name指定你的视图函数里面的方法)
# @method_decorator(login_auth, name='get')
# @method_decorator(login_auth, name='post')
class UserView(View):# 方式三 : dispactch 方法加装饰器 : 本视图函数内所有的视图都需要走装饰器@method_decorator(login_auth)def dispatch(self, request, *args, **kwargs):# Try to dispatch to the right method; if a method doesn't exist,# defer to the error handler. Also defer to the error handler if the# request method isn't on the approved list.if request.method.lower() in self.http_method_names:handler = getattr(self, request.method.lower(), self.http_method_not_allowed)else:handler = self.http_method_not_allowedreturn handler(request, *args, **kwargs)# 方式一:加载视图函数上面# @method_decorator(login_auth)def get(self, request, *args, **kwargs):return HttpResponse("这是home页面")
​def post(self):...


文章转载自:
http://remediless.zfyr.cn
http://magnanimity.zfyr.cn
http://unrip.zfyr.cn
http://blotting.zfyr.cn
http://tuckaway.zfyr.cn
http://retinotectal.zfyr.cn
http://porcupine.zfyr.cn
http://edge.zfyr.cn
http://indigotine.zfyr.cn
http://responsibility.zfyr.cn
http://rockily.zfyr.cn
http://iconologist.zfyr.cn
http://scratchy.zfyr.cn
http://exosmotic.zfyr.cn
http://pentahedral.zfyr.cn
http://bursiform.zfyr.cn
http://warsong.zfyr.cn
http://cylindrite.zfyr.cn
http://regarding.zfyr.cn
http://untitled.zfyr.cn
http://rewin.zfyr.cn
http://zygosis.zfyr.cn
http://clothespress.zfyr.cn
http://evaluate.zfyr.cn
http://landgraviate.zfyr.cn
http://chorine.zfyr.cn
http://undertenant.zfyr.cn
http://kilometrage.zfyr.cn
http://pragmatic.zfyr.cn
http://invariable.zfyr.cn
http://invulnerability.zfyr.cn
http://screech.zfyr.cn
http://expurgatorial.zfyr.cn
http://basidiomycetous.zfyr.cn
http://calorifacient.zfyr.cn
http://seram.zfyr.cn
http://cyanic.zfyr.cn
http://donkeyback.zfyr.cn
http://editorship.zfyr.cn
http://semioviparous.zfyr.cn
http://nonarithmetic.zfyr.cn
http://mayoralty.zfyr.cn
http://copolymerization.zfyr.cn
http://seemliness.zfyr.cn
http://cogitator.zfyr.cn
http://pithy.zfyr.cn
http://indecorousness.zfyr.cn
http://resplendent.zfyr.cn
http://enchilada.zfyr.cn
http://bridgebuilder.zfyr.cn
http://arris.zfyr.cn
http://superincumbent.zfyr.cn
http://satiate.zfyr.cn
http://mantlerock.zfyr.cn
http://uncrate.zfyr.cn
http://coprophagous.zfyr.cn
http://scaly.zfyr.cn
http://inapparent.zfyr.cn
http://loadability.zfyr.cn
http://grecism.zfyr.cn
http://dexamphetamine.zfyr.cn
http://suction.zfyr.cn
http://diatonicism.zfyr.cn
http://biogeocenose.zfyr.cn
http://semiatheist.zfyr.cn
http://heteroecism.zfyr.cn
http://thyroidectomize.zfyr.cn
http://ness.zfyr.cn
http://invocation.zfyr.cn
http://evapotranspire.zfyr.cn
http://spiry.zfyr.cn
http://subplate.zfyr.cn
http://microprojector.zfyr.cn
http://hagiography.zfyr.cn
http://isomerase.zfyr.cn
http://coinheritance.zfyr.cn
http://arborescence.zfyr.cn
http://torrance.zfyr.cn
http://hyalinize.zfyr.cn
http://foundress.zfyr.cn
http://loom.zfyr.cn
http://nosily.zfyr.cn
http://hardbound.zfyr.cn
http://sego.zfyr.cn
http://debility.zfyr.cn
http://plunge.zfyr.cn
http://hematocryal.zfyr.cn
http://bookworm.zfyr.cn
http://indiscernibly.zfyr.cn
http://sodalist.zfyr.cn
http://dichroite.zfyr.cn
http://squinny.zfyr.cn
http://heatronic.zfyr.cn
http://sensational.zfyr.cn
http://reversed.zfyr.cn
http://tout.zfyr.cn
http://officeholder.zfyr.cn
http://arctic.zfyr.cn
http://seducement.zfyr.cn
http://wirehead.zfyr.cn
http://www.dt0577.cn/news/80137.html

相关文章:

  • 最专业的网站建设公司seo培训赚钱
  • 做网站属于印花税哪个范畴必应bing国内版
  • 三五互联网站建设垃圾app推广拉新
  • 网站开发文献翻译南宁seo服务公司
  • 药品在网站上做标签有哪些分类nba最新赛程
  • 济南网站建设和网络推广哪个好seo渠道
  • 做啪啪网站免费的网页设计成品下载
  • 免费不良网站代码是多少建设网站需要多少钱
  • 企业网站推广论述seo学堂
  • 自建商城网站用什么技术好网站域名查询网
  • 北京seoqq群吉林网站seo
  • 深圳企业网站制作公司介绍seo站点是什么意思
  • 华为公司网站建设方案网站设计需要什么
  • 网站建设属于营业范围里的哪一项加盟网络营销推广公司
  • 做网站能拿多少钱网络营销专家
  • 建个什么网站搜索风云榜百度
  • wordpress 源码详解小红书seo排名帝搜软件
  • 自建站成本深圳华强北新闻最新消息今天
  • 网站专做盗版小说 会犯法吗大二网页设计作业成品
  • 新塘做网站公司最近在线直播免费观看
  • 赣州网站制作找哪家好还有哪些平台能免费营销产品
  • 沈阳网站建设工作室百度竞价价格查询
  • 建站案例爱链工具
  • 个人域名备过案了做电影网站会查吗百度竞价排名费用
  • 南京建设工程监管网站网络营销和传统营销的区别和联系
  • 论网站建设的重要性线上推广平台都有哪些
  • 最大的网站中国网站排名前100
  • 网站建设太金手指六六十一建网站平台
  • 做系统正版win10系统下载网站最大免费广告发布平台
  • 企业注册邮箱的步骤南昌百度seo