中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

游戲ui設計落實20條優(yōu)化措施

游戲ui設計,落實20條優(yōu)化措施,淄博專業(yè)網(wǎng)站建設哪家好,微信做模板下載網(wǎng)站有哪些cookie和session 發(fā)展史 一開始,只有一個頁面,沒有登錄功能,大家看到東西都一樣。 時代發(fā)展,出現(xiàn)了需要登錄注冊的網(wǎng)站,要有一門技術存儲我們的登錄信息,于是cookie誕生了。 cookie: - 存儲形式:k:v鍵值對…

cookie和session

發(fā)展史

????????一開始,只有一個頁面,沒有登錄功能,大家看到東西都一樣。

????????時代發(fā)展,出現(xiàn)了需要登錄注冊的網(wǎng)站,要有一門技術存儲我們的登錄信息,于是cookie誕生了。

????????cookie:

- 存儲形式:k:v鍵值對

- 存儲位置:客戶端

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

????????時代再度發(fā)展,需要有一門新的安全的技術,于是有了session。

????????session:

- 標識符,來表示我是當前用戶加密出來的數(shù)據(jù)

- 對敏感信息進行加密處理

????????- 存儲服務端 ? ?

????????- 標識符配合上你的加密串

- 把我的標識符+ 字符串全給客戶端

????????- 客戶端存儲格式 ? ?

????????- 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基于數(shù)據(jù)庫表才能使用的 ?- 必須先遷移數(shù)據(jù)庫,生成 django_session 表

- session只對當次登錄有效 ?

- 主動清除瀏覽器中本地存在的session ?

- 驗簽發(fā)現(xiàn),沒有sessionid就會自動生成新的session

- `django_sessoin`表中的數(shù)據(jù)條數(shù)取決于瀏覽器

- 同一個計算機(IP地址)上同一個瀏覽器只會有一條數(shù)據(jù)生效

- 同一個計算機(IP地址)上多個瀏覽器會有多個數(shù)據(jù)生效

- 當session過期的時候,可能會出現(xiàn)多條數(shù)據(jù)對應一個瀏覽器

- 但是這些數(shù)據(jù)不會持久化存儲,會被定時清理掉,可以手動清除也可以代碼清除

- 目的是為了節(jié)省服務器數(shù)據(jù)庫資源

????????設置session過期時間
request.session['sign'] = 'user'
request.session.set_expiry(0)
????????刪除cookie
# 刪除session
request.session.delete()
# 把瀏覽器和數(shù)據(jù)庫里面的session全部清除掉
request.session.flush()

CBV加裝飾器的三種方法

from django.utils.decorators import method_decorator
?
# 方式二:放在類視圖上面 (放的裝飾器函數(shù),name指定你的視圖函數(shù)里面的方法)
# @method_decorator(login_auth, name='get')
# @method_decorator(login_auth, name='post')
class UserView(View):# 方式三 : dispactch 方法加裝飾器 : 本視圖函數(shù)內(nèi)所有的視圖都需要走裝飾器@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)# 方式一:加載視圖函數(shù)上面# @method_decorator(login_auth)def get(self, request, *args, **kwargs):return HttpResponse("這是home頁面")
?def post(self):...

http://www.risenshineclean.com/news/27206.html

相關文章:

  • 網(wǎng)站建設硬件網(wǎng)站怎么優(yōu)化推廣
  • 江蘇城鄉(xiāng)建設職業(yè)學院就業(yè)網(wǎng)站seo賺錢項目
  • 網(wǎng)站怎么進行優(yōu)化排名福建鍵seo排名
  • 仿win8網(wǎng)站百度站長工具seo綜合查詢
  • 梅花網(wǎng)官網(wǎng)免費素材中國seo排行榜
  • 企業(yè)建站有什么好處百度秒收錄軟件工具
  • 新鄉(xiāng)網(wǎng)站開發(fā)的公司谷歌瀏覽器下載安裝
  • 網(wǎng)站建設伍際網(wǎng)絡百度搜索推廣方法
  • 最近新聞大事件摘抄游戲優(yōu)化大師有用嗎
  • 網(wǎng)站如何添加白名單百度關鍵詞收錄排名
  • 求職網(wǎng)站開發(fā)我想注冊一個網(wǎng)站怎么注冊
  • 高郵市建設網(wǎng)站龍崗seo網(wǎng)絡推廣
  • aso.net 網(wǎng)站開發(fā)營銷策略
  • 做app還是網(wǎng)站太原百度seo排名軟件
  • phpwind怎么做網(wǎng)站整站優(yōu)化工具
  • 怎樣做百度推廣網(wǎng)站天津谷歌優(yōu)化
  • 昆明學校網(wǎng)站建設長沙網(wǎng)站優(yōu)化體驗
  • 網(wǎng)站做cdn需要注意什么意思百家號排名
  • 如何做網(wǎng)站靜態(tài)頁面?zhèn)€人推廣網(wǎng)站
  • 網(wǎng)站怎么做聯(lián)系我們頁面營銷技巧培訓ppt
  • 請收網(wǎng)址999938關鍵詞優(yōu)化公司哪家效果好
  • 專業(yè)建網(wǎng)站平臺網(wǎng)絡營銷是做什么的工作
  • 中山網(wǎng)站建設哪家好seo是什么服務
  • 網(wǎng)站的排版網(wǎng)絡營銷成功的案例分析
  • 連云港專業(yè)網(wǎng)站制作公司seo快排軟件
  • 惠州seo推廣公司南寧seo平臺標準
  • 網(wǎng)站域名地址查詢網(wǎng)站創(chuàng)建
  • 如何進行優(yōu)化短視頻關鍵詞優(yōu)化
  • 網(wǎng)站模板如何編輯軟件代引流推廣公司
  • 建設網(wǎng)站一般要多錢sem工作內(nèi)容