php QQ登录 session['state'] 一直找不到 求解,该如何处理

WBOY
Release: 2016-06-13 13:21:32
Original
962 people have browsed it

php QQ登录 session['state'] 一直找不到 求解
易联主机的虚拟空间(不知道跟这个有没有关系)

使用QQsdk php 做QQ登录
按照步骤设置config和session文件
结束只有一个





//session.php 代码


/**
 * PHP SDK for QQ登录 OpenAPI
 *
 * @version 1.2
 * @author connect@qq.com
 * @copyright © 2011, Tencent Corporation. All rights reserved.
 */

/**
 * @brief 设置session配置 
 */

/**
 * CREATE TABLE `tbl_session` (
 * `session_id` varchar(255) binary NOT NULL default '',
 * `session_expires` int(10) unsigned NOT NULL default '0',
 * `session_data` text,
 * PRIMARY KEY (`session_id`)
 * ) ENGINE=MyISAM;
 */

class Session 
{
  //mysql的主机地址
  const db_host = "localhost"; //需要第三方指定ip地址 

  //数据库用户名
  const db_user = "ibrat"; //需要第三方指定自己的用户名

  //数据库密码
  const db_pwd = "ibrat"; //需要第三方指定自己的库据库密码

  //数据库
  const db_name = "ibrat"; //需要第三方指定数据库

  //数据库表
  const db_table = "ghb_session"; //需要第三方指定数据表

  //mysql-handle
  private $db_handle;

  //session-lifetime
  private $lifeTime;

  function open($savePath, $sessName) 
  {
  // get session-lifetime
  $this->lifeTime = get_cfg_var("session.gc_maxlifetime");

  // open database-connection
  $db_handle = @mysql_connect(self::db_host, self::db_user, self::db_pwd);

  $dbSel = @mysql_select_db(self::db_name, $db_handle);

  // return success
  if(!$db_handle || !$dbSel)
  return false;

  $this->db_handle = $db_handle;
  return true;
  }

  function close() 
  {
  $this->gc(ini_get('session.gc_maxlifetime'));
  // close database-connection
  return @mysql_close($this->db_handle);
  }

  function read($sessID) 
  {
  // fetch session-data
  $res = @mysql_query("SELECT session_data AS d FROM ".self::db_table." 
  WHERE session_id = '$sessID'
  AND session_expires > ".time(), $this->db_handle);

  // return data or an empty string at failure
  if($row = @mysql_fetch_assoc($res))
  return $row['d'];

  return "";
  }

  function write($sessID, $sessData) 
  {
  // new session-expire-time
  $newExp = time() + $this->lifeTime;

  // is a session with this id in the database?
  $res = @mysql_query("SELECT * FROM ".self::db_table." 
  WHERE session_id = '$sessID'", $this->db_handle);

  // if yes,
  if(@mysql_num_rows($res)) 
  {
  // ...update session-data
  @mysql_query("UPDATE ".self::db_table." 
  SET session_expires = '$newExp',
  session_data = '$sessData'
  WHERE session_id = '$sessID'", $this->db_handle);

  // if something happened, return true
  if(@mysql_affected_rows($this->db_handle))
  return true;
  }
  else // if no session-data was found,

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template