一、session概述
一、session概述
session是什么,刚开始我也不明白,非专业词典翻译为会议,会议期。作个不太恰当的比喻吧
(虽然不恰当,但意义却是一样的),session是你和网站之间的感情。
session在WEB技术中占有非常重要的份量。由于网页是一种无状态的连接程序,因此你无法得知用户的浏览状态。因此我们必须
通过session记录用户的有关信息,以供用户再次以此身份对web服务器提供要求时作确认,例
如,我们在某些网站中常常要求用户登录, 但我们怎么知道用户已经登录了呢,如果没有session的话,登录信息是无法保留的,那岂不要让用户在每一页网页中都要提供用户名和密码。
当然,session不光用于用户身份认证功能,还可能用于其它方面,以后我们会提到的。
session用中文来解释就是会话期。一个会话期开始于用户输入一个站点的网址时,结束于他离开这个站点时。session最早出现在动态脚本语言Active Server Pages中,它的功能之强大,是一句话无法说清楚的。
当php还在3.0版本时,session是它永远的痛。虽然php具有执行速度快,使用灵活,功能强大等优点,但因为session的问题,使很多站点的开发放弃了php,至少我的老板是这样认为的。当时有很多php免费函数库提供在php3上实现session的方案,但都让人感觉不正宗。就好象你花好几千大洋买的手机却配置一个很粗糙的草作的袋子一样,虽然功能是一样的,但总让人觉得别扭。php4的出现让php在session问题上有了翻身的机会。虽然它的session实现还不是很理想(主要是效率问题),但毕竟是它自己实现的,而且可以实际使用了。
那我们用session干什么呢,你说了半天,我用不上的话,你岂不有卖纸张之嫌。OK,我们来看看session有什么用:作过网站的人都有这样的体会,在一页页面中的变量(在本章都指服务器端变量,下同)是不能在下一页中用的,虽然有一些办法可以实现,比如用form,urlstring等等,但有些对于用户来说是不方便的,即使让form自动提交,但其中的延时在现今的网络状况下足以让人窒息,而这两种方法都明显加大程序员的负担。如果你正在开发一个大型项目,那这些额外的负担是不能忽略的。而有了session就好办了,session中注册的变量可以作为全局变量使用。什么,全局变量? 好极了。这样一来,你知道有什么用了吧:最主要的用于用户身份认证,程序状态记录,页面之间参数传递。

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

ccsvchst.exe is a common process file that is part of the Symantec Endpoint Protection (SEP) software, and SEP is an endpoint protection solution developed by the well-known network security company Symantec. As part of the software, ccsvchst.exe is responsible for managing and monitoring SEP-related processes. First, let’s take a look at SymantecEndpointProtection(

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

1. Implementing SMS login based on session 1.1 SMS login flow chart 1.2 Implementing sending SMS verification code Front-end request description: Description of request method POST request path /user/code request parameter phone (phone number) return value No back-end interface implementation: @Slf4j@ ServicepublicclassUserServiceImplextendsServiceImplimplementsIUserService{@OverridepublicResultsendCode(Stringphone,HttpSessionsession){//1. Verify mobile phone number if

This site reported on March 4 that DingTalk, owned by Alibaba, has received the iOS version 7.5.10 update, which supports browsers to directly enter DingTalk meetings. The log shows that by clicking on the DingTalk video conference joining link in WeChat or an external browser, you only need to verify your mobile phone number to join the meeting, making the meeting more convenient. Tested by this site, the DingTalk meeting function in WeChat currently only has a few core functions such as switching the microphone, switching the camera, inviting friends, and viewing members. To join the meeting for the first time, you need to enter a mobile phone number verification code. If you enter the meeting again within the next 30 days, you can achieve the same goal. Key shortcut login. The following is the updated content of DingTalk iOS version 7.5.10: [Attendance punch-in: shift supports setting multiple break times] Supports the attendance punch-in shift function of setting multiple break times, which is suitable for long-term work,

JavaScriptCookies Using JavaScript cookies is the most effective way to remember and track preferences, purchases, commissions and other information. Information needed for a better visitor experience or website statistics. PHPCookieCookies are text files that are stored on client computers and retained for tracking purposes. PHP transparently supports HTTP cookies. How do JavaScript cookies work? Your server sends some data to your visitor's browser in the form of a cookie. Browsers can accept cookies. If present, it will be stored on the visitor's hard drive as a plain text record. Now, when a visitor reaches another page on the site

Dual-core browser is a browser software that integrates two different browser cores. The kernel is the core part of the browser, responsible for rendering web content and executing web scripts and other functions. Traditional browsers generally use only a single kernel, such as IE browser using Trident kernel, Chrome browser using WebKit/Blink kernel, Firefox browser using Gecko kernel, etc. The dual-core browser integrates two different cores into one browser, and users can freely switch between them as needed. The emergence of dual-core browsers

Outlook app opens on Windows 11 iCloud support for Windows 11 Outlook is now available to everyone. You can add your iCloud account by clicking the gear icon in the menu, which will open the Email Accounts settings where you can manage your connected accounts. From there, click "Add Account" and connect your iCloud account. While the original Outlook client or UWP app has always supported Apple's email service, the feature is missing from the new web app for Windows 11. For those who don’t know, Microsoft is replacing the Outlook app with a new one
