PHP如何将Session存储在数据库中(3)
然后编写DatabaseSessionStore类来实现会话存储所需的方法。这个类中只有静态方法。还需要一个静态成员变量,在这里保存数据库连接,如下所示:
class DatabasesessionStore
{
private static $s_conn =null ;
//method next.
}
open和close方法分别创建和关闭数据库,如下所示:
public static function open( $sava_path, $session_name )
{
self::$s_conn = @new mysqli(’localhost’ , ‘message_user’,’secret’,'MessageBoard’);
if(mysqli_connect_errno()!=0)
return false;
else
return true;
}
public static function close( )
{
if( self::$s_conn !== NULL)
{
self::$s_conn ->close( );
self::$s_conn = NULL;
}
}
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

偶的目标是超过www.realure.cn,但现在还米有实现,至少pr和排名还有关键词都米达到,但偶相信,几个月或者半年内,偶一定有能力追上你的,呵呵。