Easy to learn how to use PHPSession _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
You can easily learn how to use PHPSession. PHP is a commonly used language for developing WEB dynamic pages. I have studied PHPSession usage and shared it with you here. I hope it will be useful to you. PHPSession refers to the language commonly used by users to develop WEB dynamic pages in PHP. I have studied the usage of PHP sessions and will share it with you here. I hope it will be useful to you. PHP Session refers to the time that a user spends browsing a website from entering the website to closing the browser.

From the above definition, we can see that Session is actually a specific concept of time. Generally, variables (server-side variables, the same below) on a page on a website cannot be used on the next page. with session, it is easy. The variables registered in the session can be used as global variables. In this way, the session can be used for user identity authentication, Program Status record, and parameter transfer between pages.

PHP Session usage

Php3 itself does not implement the session function. we can only implement it using other methods. The most famous one is phplib. Phplib's most basic functions include user authentication, Session management, permission and database abstraction. The following describes how to use phplib to implement a session. First install phplib (the environment is win2000 + php3.0.16 + Apache1.3.12 + phplib7.2c + mysql3.23.21 for win32). first, unbind phplib, which contains a "php" directory, copy the directory to the installation directory of Apache. For example, if Apache is installed in the d: Apache Directory, copy the "php" directory to the d: Apache Directory, and paste the pages directory under the phplib Directory (excluding the directory itself) copy the file and directory to d: Apachehtdocs.

The phplib class library needs to be initialized based on the system. you may need to modify the local. inc file, which contains some basic parameters that can be modified based on the actual situation of your machine.

Change a program in the d: Apachephpprepend. php file as follows:

 
 
  1. If (! Isset ($ _ PHPLIB) or! Is_array ($ _ PHPLIB )){
  2. $ _ PHPLIB ["libdir"] = "d:/Apache/php/"; // path of the php directory under phplib
  3. }

Modify the d: Apachephplocal. inc file:

 
 
  1. Class DB_Example extends DB_ SQL {
  2. Var $Host="Localhost"; // Host name of the mysql database
  3. Var $Database="Test"; // Database name
  4. Var $User="Root"; // Database username
  5. Var $Password="1234567"; // Database user password
  6. }

Finally, the initial table is generated based on the create_database.mysql file in the stuff subdirectory under the phplib directory. For every page using phplib, you must first find the class library file necessary to run phplib. the auto_prepend variable is set in ini. phplib contains a prepend. php file, and specify auto_prepend as "d:/Apache/php/prepend. php "(with quotation marks), the pages will automatically contain the phplib class library. we can also add the directory where the phplib class library is located to the include variable so that you can find these files. The above are some basic methods used by PHP Session. have you learned this?


The usage of the reset Session is here to share with you and hope it will be useful to you. PHP Session refers to the user in the login...

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.