Session implementation in php3 and 4

Source: Internet
Author: User
Php3, 4 session implementation php3, 4 session implementation <br/> There is no such thing as session in php3, but what should we do? Don't worry, there are many people who implement session in php3 and 4.
There is no such thing as session in php3, but we need it again. what should we do? Don't worry. many people have done this for you. the most famous one is phplib. You can go abroad
And can be downloaded from most php sites in China. The first thing we need to do is to combine phplib and php3 to make it work. To achieve this, we need to install phplib first.
It's easy to follow me (the following method is passed on win2000 + php3.0.16 + apache1.3.12 + phplib7.2c + mysql3.23.21 for win32)
Phplib has the following basic functions: user authentication, Session management, permission abstraction, and database abstraction.
How to use phplib to implement the session function?
1. first, unbind phplib. there is a directory named "php" in it, and copy the directory to the installation directory of apache. The following uses the author's machine as an example:
My apache is installed in the d: apache Directory. I copy the above "php" directory to d: apache, and copy the files and directories under the pages directory under phplib together
D: In apachehtdocs, note that the directory is not included.
The phplib class library needs to be initialized according to the system. you can modify the local. inc file, which contains some basic parameters. you can modify the class library based on the actual situation of your machine.
Change a program in the d: apachephpprepend. php3 file as follows:

If (! Isset ($ _ PHPLIB) or! Is_array ($ _ PHPLIB )){
$ _ PHPLIB ["libdir"] = "d:/apache/php/"; // change the path to the php directory under phplib.
}

Modify the d: apachephplocal. inc file as follows:

Class DB_Example extends DB_ SQL {
Var $ Host = "localhost"; // Host name of your mysql database
Var $ Database = "test"; // Database name
Var $ User = "root"; // database username
Var $ Password = ""; // database user Password
}

In the final step, execute the create_database.mysql file in the stuff directory in the unlocked phplib directory to generate the initial table.
Let's explain how phplib works. every page using phplib must first find the class library file required to run phplib. we can set auto_prepend in php3.ini.
Variable. the phplib distribution package contains a prepend. in the php3 file, specify auto_prepend as "d:/apache/php/prepend. after php3 "(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. of course, the most benzene method is to specify the absolute path of phplib, which is not a good idea and is too portable!
Step 2: on every page using phplib, you must first call the page_open function for initialization. This will tell phplib that you will use status save now or in the future.

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.