Conversation sent from Changsha

Source: Internet
Author: User
Start treating a psychiatrist: good. How do you feel today, Victor? Patient: not good, doctor. I 've been feeling a little depressed recently... why is that, Victor? Patient: I don't know, doctor. I don't have a good sleep, and I have no appetite at all. One day we went to an Italian restaurant and asked for macaroni -- but they started treatment when they brought it up.

Psychologist: good. How do you feel today, Victor?

Patient: not good, doctor. I feel a little depressed recently...

Psychologist: why is that, Victor?

Patient: I don't know, doctor. I don't have a good sleep, and I have no appetite at all. One day, we went to an Italian restaurant and asked
Face-but when they bring it up, I cannot eat it at all. I have been watching it, and in my head I have been echoing "female high"
Music...

Psychologist: how is the family?

Patient: they are all good, I think. Marge spent most of her time in the kitchen and tried the recipe she downloaded from the Internet. The children go out early every day.
But now they are starting to eat at Burger King. Then I cannot blame them.

Psychology doctor: work-all right?

Patient: not very good-I have an abusive devil boss who plans to beat me and turn my life into the same way as Dilbert Zone!

Psychologist: Tell me about him.

Patient: Well, you know what I do-I am a web programmer at Used Socks. Inc. Our new website will be available next week
We are doing something totally different-an online store for people to sell their old things. We got some good people
RMB 6 million. if we become the most popular old thing portal on the web, we can get more investment.

Psychologist: It sounds good to you.

Patient: You are right. However, one day the boss came in and said he gave me a job to develop a shopping cart in an online store. He explicitly wants
Please use something called "session. Of course, it just makes things interesting. He says he wants to finish and run it in two days... abuse
Crazy, abnormal!

Psychologist: Is there a problem?

Patient: Yes, especially first, I don't know what the "session" is or how to use it. I mean, I thought it was a session.
Is short-term treatment for a patient-one thing we are doing.

Psychologist: Oh, Victor, Victor... is that a problem for you? I think I may have something to help you...
Stateless Seattle

To impress young women who can hear the conversation, the joke is one of the most common things: "HTTP is
A stateless protocol. The Internet is a stateless development environment ". In simple terms, HTTP (HyperText Transfer Protocal)
As the backbone of the web, the protocol cannot remember the identity of the user connecting to a website. Therefore, requests to web pages are considered unique and independent.
Connections have nothing to do with connections before it -- this is very similar to the actions of teenagers who love adventure today,
They drink until midnight every day. The next morning they wake up and don't remember what happened. they go out to do the same thing at night, over and over again...

Now, if you are surfing from one site to another with no aim, there is no problem. But when you want to buy a few
What will happen to this book? "In a stateless environment, it is very difficult to remember all the items on your shopping list because of the HTTP protocol.
This stateless nature makes it impossible to track selected items.

Therefore, a method is required to make it possible to remember the status, and to track user connections and save things that connect to specific data.
Therefore, a "cookie" is generated, which allows the Web site to store customer-specific information in a file of the customer's system, and at any time
You can retrieve information from the file during the request. Therefore, in the preceding shopping cart example, the selected item can be added to the cookie and
The consumer can be taken out and displayed in the shopping list during checkout.

There is a problem with the cookie-based solution, that is, it requires the cookie to be accepted by the customer. Therefore, there is another solution
Session is used to store a specific small piece of data when a customer accesses a Web site. This session
Session data is saved during the entire access period. A session can be considered as an information basket, which stores the host variable pair.
These variables exist throughout the access period and can be processed at any time. This method provides one for the stateless features of the protocol.
Stream solution, and today many large websites can track and save information for personal and commercial transactions.

Each session to be created has a unique identifier string, which is sent to the client and generated on the server.
The entry that uniquely identifies a string, either in a text file or in a database. Now you can register any session variables -- these
Common variables can save text or numeric information and can be read or written through session.

Now, if you have followed the open source code movement, you already know PHP, the most popular scripting language on the planet. Latest
The version is PHP4, which supports session creation and management. in the following pages, we will show you how to use it. If
You are still using PHP3, don't be disappointed-we will also involve PHPLIB, which includes a group of powerful PHP Objects that can be found at PHP3-based sites
Add seamless session management.

On the following pages, we assume that you already have a site that supports PHP4 or PHPLIB. If not, you should download these packages and
Install them on your development machine. PHP4, is a quality code, can be found in the PHP site http://www.php.net
The latest PHPLIB version can be found at http://phplib.netuse.de.

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.