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