thinkphp2.1整合wordpress2.2登录cookie状态

thinkphp和wordpress需保证SESSION在同一路径,cookie在同一域.paopao8.com
//登录时thinkphp
//用SESSION传thinkphp用户的ID到wordpress

$_SESSION['user_id']  = $rset['user_id'];
//设置登录后wordpress状态cookie开关
setcookie("wordpress_on",  "1",   time()+3600, "/", ".paopao8.com", 0);

//退出时
//注销SESSION
unset($_SESSION['cityos_user_id']);
//注销ordpress状态cookie开关
setcookie("wordpress_on", NULL, time()+3600, "/", ".paopao8.com", 0);

wordpress程序wp-load.php最下面加入

//Session 路径
	session_save_path('xxx\gameweb\Runtime\Session');
//判断wordpress状态cookie开关
	if ($_COOKIE['wordpress_on']){
	session_start();
	$id1 = $_SESSION['user_id'];
	wp_set_auth_cookie( $id1, false, '' );
	setcookie("wordpress_on", NULL, time()+3600, "/", ".paopao8.com", 0);	

	}
© 版权声明
THE END
喜欢就支持以下吧
点赞0
分享