/** @文件 yz.php @site http://bbs.it-home.org*/require_once('Auth.php'); function show_login_form () { echo ' username: password: ' ; } $options=array('dsn'=>'mysql://root:1@localhost/zs', 'table'=>'users', 'usernamecol'=>'user_name', 'passwordcol'=>'user_passwd', 'cryptType'=>'', 'db_fields'=>'*', ); $auth=new Auth('DB',$options,'show_login_form'); ?> $auth->start(); if($auth->checkAuth()){ echo "ok"; echo ""; echo "add"; }else { echo "error"; } //$auth->setSessionName($auth->getAuthData('user_name')); ?> 复制代码 二、yzh.php 传递登录后的session function back(){ echo 'back'; } require_once('Auth.php'); $auth=new Auth('DB',$option,'back'); $auth->start(); if($auth->checkAuth()) { echo "this is a session page,welcome "; echo "{$auth->getUserName()}"; } ?> 复制代码