Implement the SESSION function in PHP3 (3)

Source: Internet
Author: User

Example: test_session.php3

<? Php require ("session. inc. php3 ");
Require ("cookie. inc. php3 ");
?>
<? Php
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! ");
?>
<! Doctype html public "-// W3C // dtd html 3.2 Final // EN">
<Html>
<Head>
<Title> Session/Cookie-test </title>
</Head>
<Body>
<H2> This Page shocould show how to handle the "session. inc. php3" library <H3> We will use a mask with a record showing routine <? Php
If ($ show ){
If (session_read ()){
$ Username = $ session [username];
$ Userpass = $ session [userpass];
Echo "<P> session [username]: $ username
Session [userpass]: $ userpass ";
}
}
Else {
$ Session [username] = "yourid ";
$ Session [userpass] = "12345 ";
If (! Session_write ()){
Print $ sess_error;
} Else {
Echo "<p> session [username] is set to: $ session [username]
";
Echo "session [userpass] is set to: $ session [userpass]
";
Echo "<a href = '$ PATH_INFO? Show = 1'> test the role of the SESSION </a> ";
}
}
?>

</Body>
</Html>

Original Author: Unknown

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.