Implement the SESSION function in PHP3 (3) _ PHP Tutorial

Source: Internet
Author: User
Implement the SESSION function in PHP3 (3 ). Example: test_session.php3? Phprequire (session. inc. php3); require (cookie. inc. php3 );?? Phpsession_checkid (20); if the session becomes invalid after 20 minutes, you need to set the mysql connection example program: test_session.php3.

Require ("cookie. inc. php3 ");
?>
Session_checkid (20); // after 20 minutes, the session becomes invalid.
// Set the mysql connection parameters below
Mysql_connect ('localhost', 'user', 'pass') or Die ("can't connect to db! ");
?>



Session/Cookie-test


This Page shocould show how to handle the "session. inc. php3" library
We will use a mask with a record showing routine
If ($ show ){
If (session_read ()){
$ Username = $ session [username];
$ Userpass = $ session [userpass];
Echo"

Session [username]: $ username
Session [userpass]: $ userpass ";
}
}
Else {
$ Session [username] = "yourid ";
$ Session [userpass] = "12345 ";
If (! Session_write ()){
Print $ sess_error;
} Else {
Echo"

Session [username] is set to $ session [username]
";
Echo "session [userpass] is set to: $ session [userpass]
";
Echo "test the role of the SESSION ";
}
}
?>




Original Author: unknown

Why? Php require (session. inc. php3); require (cookie. inc. php3 );? ? Php session_checkid (20); // after 20 minutes, the session becomes invalid. // you need to set up mysql connection...

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.