在PHP3中实现SESSION的功能(三)
程序员文章站
2022-12-26 10:11:00
示例程序:test_session.php3
示例程序:test_session.php3
<?php require( "session.inc.php3");
require("cookie.inc.php3");
?>
<?php
session_checkid( 20 ); //20分钟后session失效
//下面你需要设置mysql的连接参数
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-测试</title>
</head>
<body>
<h2>this page should show how to handle the "session.inc.php3" library</h2>
<h3>we will use a mask with a record showing routine</h3>
<?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]被设置成:$session[username]
" ;
echo "session[userpass]被设置成:$session[userpass]
" ;
echo "<a href='$path_info?show=1'>测试一下session的作用</a>" ;
}
}
?>
</body>
</html>
原作者:不详
<?php require( "session.inc.php3");
require("cookie.inc.php3");
?>
<?php
session_checkid( 20 ); //20分钟后session失效
//下面你需要设置mysql的连接参数
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-测试</title>
</head>
<body>
<h2>this page should show how to handle the "session.inc.php3" library</h2>
<h3>we will use a mask with a record showing routine</h3>
<?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]被设置成:$session[username]
" ;
echo "session[userpass]被设置成:$session[userpass]
" ;
echo "<a href='$path_info?show=1'>测试一下session的作用</a>" ;
}
}
?>
</body>
</html>
原作者:不详
下一篇: php 冒泡排序 交换排序法