长沙发上的对话(一)
开始治疗
心理医生: 好。你今天感觉怎么样,维克多?
病人: 不太好,医生。我近来感到有点忧郁...
心理医生: 那是为什么,维克多?
病人: 我不知道,医生。我睡眠不太好,而且我一点胃口也没有。有一天我们去一个意大利餐馆,要了通心面 -- 但时当他们把它端上来的时候,我一点也吃不下去。我就一直看着它,在我的头里一直回荡着“女高音”的主题曲...
心理医生: 家里怎么样?
病人: 都很好,我想。Marge大部分时间都在厨房,试她从网上下载的菜谱。孩子们每天很早就出去了,一般在吃饭时才看得见他们,但是现在他们开始在Burger King吃了。那我也不能责备他们。
心理医生: 工作 - 都很好吧?
病人: 不太好 - 我有一个虐待成性的魔鬼老板,他打算打我的生活变成象Dilbert Zone一样!
心理医生: 跟我说一说他吧。
病人: 好,你知道我是做什么的 - 我是一个在Used Socks. Inc.的web程序员。下个星期我们的新网站就要使用了,我们正在做着完全不同的东西 -- 一个在线商店,供人们出售他们的旧物。我们得到了一些好心人的投资 - 6百万元,如果我们成为在web最受欢迎的旧物门户,我们还可得到更多的投资。
心理医生: 听上去对你不错嘛。
病人: 你说的对。但是,然后有一天老板进来,他说他交给我一项开发在线商店购物车的工作。他明确地要求我用什么叫“session”的东西。当然,只不过让事情变得有趣,他说他想在两天内做完并能运行...虐待狂、变态!
心理医生: 有问题吗?
病人: 有,特别是首先我根本不知道“session”是什么,或怎么去用它。我意思是说,我原以为一个session 就是对一个病人的短期治疗 -- 有一点象我们正在做的一样。
心理医生: 哦,维克多,维克多...这就是麻烦你的事吗?我想我可能有东西能帮助你...
西雅图无状态
开低级玩笑的人为了给能听到谈话的年轻女性留下印象,互相之间最经常说的事情之一就是:“HTTP是一种无状态协议,Internet是无状态开发环境”。用简单的话来讲,HTTP(HyperText Transfer Protocal )协议,作为web的骨干,不能够记住与一个网站连接用户的身份,所以对web页的请求被看作是唯一和独立的连接,与在它之前的连接无论如何都没有关系 -- 这一点与今天很多爱冒险的十几岁的年轻人的行为很象,他们每天喝到深夜,第二天早晨醒来对发生过什么都不记得了,晚上再出去做同样的事,一遍又一遍...
现在,如果你是漫无目的地从一个站点冲浪到另一个,没有什么问题。但是当你想从Amazon.com上买几本书会怎么样呢?“在一个无状态的环境中,记住所有在你的购物单上的物品是非常困难的,因为HTTP协议的这种无状态的性质使得跟踪选中物品是不可能的。
因此就要求一种能够使记住状态成为可能的方法,能够跟踪用户的连接并且保存连接特定数据的东西。因此产生了“cookie”,它可以允许Web 站点在客户系统的一个文件中保存客户特定信息,并且当任何时候请求时都可以从文件中取出信息。所以,在上面的购物车例子中,被选中的商品可以加到cookie中,并且在消费者结帐时,可以被取出并呈现在购物单中。
基于cookie的解决方案存在一个问题,那就是它要求cookie能够被客户所接受。所以,有另一种解决办法就是使用“session”,当一个客户访问一个Web站点时,用它来保存特定的一小块数据。这个会话(session)数据在整个访问期间被保存下来。一个session可以被看成一个信息篮,它保存着主机的变量对。这些变量对在整个访间期间都存在,并且可以在任何时刻被处理。这个方法对协议的无状态的特点提供了一流的解决办法,并且在今天很多大型的网站上,可以跟踪和保存信息,用于个人和商业交易。
每一个被创建的session 都有一个唯一的标识串,这个串被发送到客户端,同时在服务端也生成了同样唯一标识串的入口,或者放在文本文件或者在一个数据库中。现在就可以注册任何的session 变量 -- 这些普通的变量可以保存文本或数值信息,可以通过session 被读出,或写入。
现在,如果你已经跟随着开放源码运动,你已经知道了PHP ,在这个星球上最热门的脚本语言。最新的版本是PHP4,包括了对session的创建和管理的支持,在下面的几页中,我们将向你展示如何使用它。如果你还在使用PHP3,不要失望 -- 我们也将涉及PHPLIB,它包括一组强大的PHP对象,可以在基于PHP3的站点上加入无缝的session管理。
在下面几页中,我们假设你已经有一个支持PHP4或PHPLIB的站点。如果还没有,你应该下载这些包,并且将它们安装到你的开发机器上去。PHP4,是一个质量优良的代码,可以在PHP站点 http://www.php.net找到,最新的PHPLIB版本可以在http://phplib.netuse.de/找到

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.

Cookies on the mobile phone are stored in the browser application of the mobile device: 1. On iOS devices, Cookies are stored in Settings -> Safari -> Advanced -> Website Data of the Safari browser; 2. On Android devices, Cookies Stored in Settings -> Site settings -> Cookies of Chrome browser, etc.

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Common problems and solutions for cookie settings, specific code examples are required. With the development of the Internet, cookies, as one of the most common conventional technologies, have been widely used in websites and applications. Cookie, simply put, is a data file stored on the user's computer that can be used to store the user's information on the website, including login name, shopping cart contents, website preferences, etc. Cookies are an essential tool for developers, but at the same time, cookie settings are often encountered
