Differentiation and understanding of sessions and cookies

Source: Internet
Author: User
Tags servervariables microsoft iis

Session first

The debate on the session seems to have never been stopped, but the number of people who can understand the session should be more than 90. But let's talk about it. Don't be too old ~

Some people are in favor of session, while others are in disapproval. But what is the problem. Let me know what I think. Do not lose anything if you have any mistakes, except for gold bars and coins.

Some people should know that I am a leaderProgramBut here we will not talk about the design, but we will look at the session from some practical perspectives.

First, let's talk about what a session is. A session can store information about the Internet Explorer of a user and any window opened through the current window. Why. Next, let's take a look at how the session is started. After you open IE and browse the website, a command will be sent to request the sessionid and the download permission for each type of data, the film, sound, and Flash.
Actual data transmission content: IE to the server
Get, HTTP, 1.1
Accept: image/GIF, image/X-xbitmap, image/JPEG, image/pjpeg, application/X-Shockwave-flash ,*/*
Accept-Language0: ZH-CN
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
HOST: www.jh521.com
Connection: keep-alive
The server will return an unused sessionid for IE to use. At that time, ie will store the returned sessionid.

At the same time, the download data on the relevant page is returned, as follows: Server to IE
HTTP/1.1 200 OK
Server: Microsoft-Microsoft IIS/5.0
Date: Sun, 30 Nov 2003 16:41:51 GMT
Content-Length: 21174 .. Content-Type: text/html
Set-COOKIE: aspsessionidcacbbbrt = ibomfonaojfeebhbpienjffc; Path =/
Cache-control: Private
Then the page htmlCodeIn this case, the sessionid of this ie Program (not a client) is ibomfonaojfeebhbpienjffc. When ie accesses any ASP program on this site, it will send ibomfonaojfeebhbpienjffc to the server, the server will know that ibomfonaojfeebhbpienjffc indicates you and set session ("name") = "name" on the server as Session ("ibomfonaojfeebhbpienjffc") ("name ") = "name"
Or
Session (sessionid) ("name") = "name"
In this way, sessions are separated from users.
When the server reports this ID, it will check whether the ID is used. If there is another
It won't let you repeat it. If you want to simulate someone's session ID for spoofing, you can. However, it is possible to obtain the signal transmitted by the other party's IE and ensure that the sessionid is not canceled at that time.

However, if I had time, I could use the post signal to find the name and pass. I don't have to worry about it. Some people must understand how sessionid works. So they are looking at cookies. Some people say that sessionid is a cookie. Technically, they are not similar, however, it is a working mode in which users and servers transmit private data. when I set the cookie, the server will send an instruction to IE. IE generates and stores cookies through this network command, and obtains this information at a specific time, such as when accessing this site and the cookid is valid.

So why use cookies instead of session?
See the difference

Effective time and storage-based content transmission
Cookie can be set and the plaintext information is kept locally

Session is not closed in IE and the server does not time out. Only sessionid

If you do not need to enter the user name or password for the next login to the website, you can only use cookies,

Because it can be retained for a long time (before the cookie record is deleted or the expiration date)

The session is not allowed. It will not be retained for too long, and IE will automatically clear the sessionid record after it is disabled.

The new sessionid will be requested during the next login.

When the server wants to verify the user's status through the user's personal variables, it cannot use cookies.

If the user permission is set to user. During ie access, the user's plaintext is transmitted to the server.

So what if I modify the cookie record directly and change the user to admin ~~

This is troublesome.

However, using cookies is the best way to store information such as user names and passwords or website color schemes.
Request. servervariables ("http_referer ")

I want some people to use this request. servervariables ("http_referer ")
To carry out some key restrictions, especially to deal with remote submission and illegal intrusion.
So I will remind you that the http_referer information obtained by the server is completely transmitted to the server by IE, and can be simulated
In addition, it is not difficult. In less than half an hour, you can use VB to create an intrusion Program Against http_referer.

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: info-contact@alibabacloud.com 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.