The dialogue on the couch (i)

Source: Internet
Author: User
Tags variables requires




Start the treatment.

Psychiatrist: Good. How are you feeling today, Victor?

Patient: Not very well, doctor. I'm feeling a little blue lately ...

Psychiatrist: Why, Victor?

Patient: I don't know, doctor. I don't sleep very well, and I have no appetite at all. One day we went to an Italian restaurant and got a heart--but when they brought it up, I couldn't eat at all. I have been looking at it, in my head has been echoed the "soprano" theme song ...

Shrink: How's home?

Patient: All very well, I think. Marge spent most of his time in the kitchen trying to download recipes from the Internet. The children go out early every day and usually see them at dinner, but now they start eating at Burger King. Then I can't blame them.

Psychiatrist: Work-All right?

Patient: Not so good-I have a sadistic devil boss, he is going to hit my life to become like Dilbert Zone!

Psychologist: Tell me about him.

Patient: Well, you know what I do--I'm a Socks in used. An INC web programmer. Next week our new site is going to be used, and we're doing something completely different-an online store for people to sell their old stuff. We got some good people's investment-6 million dollars, and if we become the web's most popular junk portal, we can also get more investment.

Psychiatrist: Sounds good to you.

Patient: That's right. But then one day the boss came in and he said he gave me the job of developing an online store shopping cart. He explicitly asked me to use something called "Session". Of course, just to make things interesting, he said he wanted to finish in two days and be able to run ... Sadistic, perverted!

Psychologist: Is there a problem?

Patient: Yes, especially first I don't know what "session" is or how to use it. I mean, I thought a session was a short-term treatment for a patient--a little bit like we were doing.

Psychologist: Oh, Victor, Victor ... Is that what's bothering you? I think I might have something to help you ...
Seattle No Status

One of the most common things to say to a young woman who can hear a conversation is that "HTTP is a stateless protocol and the Internet is a stateless development environment". In simple terms, the HTTP (Hypertext Transfer protocal) protocol, as the backbone of the web, cannot remember the identity of the user who connects to a Web site, so the request to the Web page is considered to be the only and independent connection, no matter what the connection before it- -This is very much like the behavior of many adventurous teens today, they drink late at night, wake up the next morning and don't remember what happened, go out to do the same thing again, over and over again ...

Now, if you are aimlessly surfing from one site to another, there is no problem. But what if you want to buy some books from the Amazon.com? In a stateless environment, it is very difficult to remember all the items on your shopping list because the stateless nature of the HTTP protocol makes it impossible to track selected items.

So it requires a way to make the state of mind possible, to keep track of the user's connections and to save things connected to specific data. This creates a "cookie" that allows a Web site to hold customer-specific information in a file in a client system, and to retrieve information from a file whenever it is requested. So, in the shopping cart example above, the selected item can be added to the cookie and can be taken out and present in the shopping list when the consumer checks out.

A problem with a cookie-based solution is that it requires the cookie to be accepted by the customer. So, another solution is to use "session", when a customer visits a Web site, use it to save a specific piece of data. This session data is saved throughout the visit. A session can be viewed as an information basket that holds the host's variable pairs. These variables exist throughout the visit and can be processed at any time. This approach provides a first-rate solution to the stateless nature of the protocol, and can be tracked and saved for personal and commercial transactions today on many large web sites.

Each session that is created has a unique identifier string that is sent to the client and also generates an entry for the same unique identity string on the server, either in a text file or in a database. You can now register any session variables--These ordinary variables can hold text or numeric information that can be read out or written through the session.

Now, if you've followed the open source movement, you already know PHP, the hottest scripting language on the planet. The latest version is PHP4, including support for session creation and management, and in the next few pages we'll show you how to use it. If you're still using PHP3, don't be disappointed-we'll also involve Phplib, which includes a powerful set of PHP objects that can add seamless session management to a PHP3 based site.

In the next few pages, let's say you already have a site that supports PHP4 or phplib. If not, you should download the packages and install them on your development machine. PHP4, is a good quality code, can be found in the PHP site Http://www.php.net, the latest phplib version can be found in 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.