首先解释一下什么是Session,如果你不知道的话。当一个访问者来到你的网站的时候一个Session就开始了,当他离开的时候Session就结束了。本质是来说,cookie是和浏览器有关系,而Session变量就可以存一些资源变量在服务器上面。PHP4用文件存储Session变量,但理论上可以用数据库或共享内存来做这件事。 所有的页面都用PHP4的Session必须用Session_start()功能函数来告诉PHP4引擎来取有关的Session到内存中 。函数Session_start()可以在cookie域里或请求的参数中取得Session_id为了响应http请求。如果不能找到 SessionID就新建一个Session。 什么是Session变量? Session变量是个有规律的全局变量,当一个Session变量被注册,用PHP4可以在所有的页面上得到Session 的值。用Session_register("variable_name")可以注册一个Session变量。在所有并发的的用Session就使用 Session_start()函数,变量的值将作为一个Session变量注册为Session。 我们能作什么? 通常有很多的方法来管理Session和Session变量,我将给你个例子。说你将建一个商业站点,象我这样的, 你可能想保持已经被承认的用户当前的名字,或有多少的新消息用户已经得到。为了不在从数据库里读取,你 有两个方法可以做: 1.1.你可以用三个cookie 。authenticated_user - 当前的用户名称 。num_messages - 他得到的信息的数量 。expire_time - 何时重新读取信息数量 2.2.用sessions和新建三个session变量 第一个方法安全性不好,一些人可以得到cookie进入他人的领域。 用sessions用户仅得到一个cookie,安全的多。 缺点 session给了你自由,过度的用session会影响脚本语言的使用。虽然PHP4的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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
