The conversation on the couch (i) _php tutorial

Source: Internet
Author: User
Start Treatment

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

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

Psychiatrist: That's why, Victor?

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

Psychologist: How's home?

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

Psychiatrist: Work-All right?

Patient: Not very good-I have a sadistic devil boss who intends to beat my life into a Dilbert zone!

Psychiatrist: Tell me about him.

Patient: Well, you know what I do-I'm a Socks in used. Inc. 's web programmer. Our new website is going to be in use next week, and we're doing something completely different-an online store for people to sell their stuff. We got some kind of good people's investment-6 million yuan, if we become the most popular web portal in the world, we can also get more investment.

Psychiatrist: Sounds good to you.

Patient: you're right. But then one day the boss came in and he said he was handing me a job developing an online store shopping cart. He specifically 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!

Psychiatrist: Is there a problem?

Patient: Yes, especially first I don't even 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.

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

Seattle No Status

A low-level joke. To impress the young women who can hear the conversation, one of the most common things to say is "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 a user connected to a Web site, so a request for a page is considered to be a unique and independent connection, regardless of the connection before it- -This is similar to the behavior of many teenage teenagers who love to take risks today, they drink every day? Night, the next morning to wake up to happen to have nothing to remember, at night to go out to do the same thing, 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 Amazon.com? " In a stateless environment, it is very difficult to remember all the items on your shopping list, because this stateless nature of the HTTP protocol makes it impossible to track selected items.

Therefore, it requires a way to make the remembered state possible, to keep track of the user's connection and to save things that connect to specific data. Thus, a "cookie" is created that allows a Web site to store customer-specific information in a file in a customer's system, and to remove information from a file whenever requested. So, in the shopping cart example above, the selected item can be added to the cookie and can be taken out of the shopping list when the consumer is checkout.

One problem with cookie-based solutions is that it requires cookies to be accepted by customers. Therefore, there is another solution is to use "session", when a customer visits a Web site, it is used to save a specific piece of data. This session data is saved during the entire visit. A session can be viewed as a basket of information, which holds the host's variable pairs. These variables are present during the entire visit and can be processed at any time. This approach provides a first-class solution to the stateless nature of the protocol, and on many large Web sites today, information can be tracked and stored for personal and commercial transactions.

Each session that is created has a unique identity 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 or written through the session.

Now, if you have followed the open source movement, you already know PHP, the most popular scripting language on the planet. The latest version is PHP4, which includes 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 be involved in Phplib, which includes a powerful set of PHP objects that can add seamless session management to PHP3-based sites.

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/.


http://www.bkjia.com/PHPjc/532660.html www.bkjia.com true http://www.bkjia.com/PHPjc/532660.html techarticle start treating a psychiatrist: OK. How are you feeling today, Victor? Patient: Not very well, doctor. I've been feeling a little blue lately ... Psychiatrist: That's why, Victor? Patient ...

  • Related Article

    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.