One of the basic component for every PHP application is the user account system. User can login , logout and register. This post talks about auto login. The user can select "remember me" or "auto login", so after the user login successfully, when the user come back at any later time in a specific period, the user auto login.
MongoDB is scalable document oriented database. This make it a good choice to store of the session information of the users. With MongoDB, your application can grow as the users grows, for example, a Social Network Site.
A special cookie with a name "SID" is used to identify the current session. To start a session , first check the cookie, if there is a cookie named with "SID", then load the session data from MongoDB, if not, create a new session and insert a record that contains session data into database.A special cookie with a name "SID" is used to identify the current session. To start a session , first check the cookie, if .
The non-capture parentheses is a confusing regular expression element. The non-capture operator has a special notation (?:).
Here is an example in PHP:
In last post we demonstrate the basic CRUD in MongoDB. Lets get some advanced query technique.
MongoDB support chained calling, you can filter result by chaining, to select the first 3 recoreds:
Install PEAR is very easy, just download http://pear.php.net/go-pear.phar and run
Then you can install mongodb like this:
A very common situation in web development is the category tree, in its nature , its just a recursive traversal of a tree data structure. This post will demonstrate the method of generating a tree while traversing the data strucute.
Step 1. Create a database table to store the category data:
A typical file name in windows is like "file.txt". How to get the extension name with php script?
If you think its too many lines:
PHP has built in networking api to access all kinds of services. Here is a script you can type in a command line window to upload a folder and all its sub directories to a FTP server. Sometimes it will be very handy with a command to do this kind of job.
Its very useful to record the site visitor information like ip address, search keywords, visit url...
Today I will write a simple php script to achieve that. First we need a database table to store the information. Here is the table: