Website user identification Tips! Django Implementation cookie! You don't give full marks for this wave?

Source: Internet
Author: User


Principle Introduction

Code implementation

Process Analysis

Tracking cookies

Principle Introduction

Session Introduction

A session is a key-value pair that is stored on the service. When the user logs on successfully, the server generates a session, which is key and value, respectively. Key sent to the browser, when the browser to access the server to carry key, the server to determine the key to know the identity of the login.

A person self-study is very likely because of insufficient power to give up halfway, you can try to join one or a few suitable for their own network (QQ, community, etc.), to find like-minded learning partners, mutual communication, mutual promotion. If you want to learn to communicate, welcome to me. Private key words: will get different information! The system insists that the keyword will be sent automatically. Send separately! 01 or 02

Django Code implementation

1, create the project, the name is Coookie

1 django-admin startproject cookie

5. Configure user data tables to store user names and passwords.


6. Complete the login logic function

7. Create a paging file

The HTML file to use in the function. Create a new Templates folder under the online folder and save the following three HTML files.




8. Create a data table

Create a table of databases based on the user class created in file models.

Python Makemigrationspython Migrate

The final file directory

9. Open Service

2. There is a "show cookie" button in privacy and security, which stores the cookies stored by the browser when landing on each website.

3, in the cookie cache search the landing URL, for me is Start with the authentication of a single Django-issued middleware when registering a user.

5. The cookie is deleted after the exit. This is if in the request Http://, then jumps to the login interface, needs to log in.

The reason for the length of the session is left in the next article. The above code in my environment is running normally, if there are any problems in the learning process or the text is not clear, please feel free to communicate.

Website user identification Tips! Django Implementation cookie! You don't give full marks for this wave?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.