Example Program : 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 </H2>
<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