02: django Advanced articles

1.1 cookie

  1, cookie Introduction

      1. cookie essence is the client hard disk to store key-value pairs, the use of this feature can be used for user authentication

      2. For example: { "username": "dachengzi"} # url to access the information again will carry over

  2, the front end of cookie operation
      instructions: using the following method of operation must be introduced into the cookie jquery.cookie.js

      1. Get distal cookie value:  var .cookie V = $ ( 'per_page_count'); 

      2. The front end of the cookie value:  $ .cookie ( 'per_page_count', V); 

  3, back-end operations cookie

      说明: response = HttpResponse(...)  或  response = render(request, ...)

      1. Set rear cookie value:   response.set_cookie ( 'username', "zhangsan")

      2. After the rear end to the cookie value:  request.COOKIES.get ( 'username') 

 

Guess you like

Origin www.cnblogs.com/xiaonq/p/10959010.html