PHP - 会话不起作用 - Safari

时间:2015-10-15 19:26:30

标签: php mysql session safari

所以,我有一个登录脚本。如果它是正确的细节,它做一个简单的工作并创建一个会话。出于某种原因,除了Safari之外,它适用于所有浏览器。

代码:

-(void)viewWillLayoutSubviews{

    [super viewWillLayoutSubviews];

      [self.view setFrame:CGRectMake(100, 100, 100, 100)];

}

上面的代码是用于获取数据并查看数据是否正确的函数e.t.c。

调用它并通过执行以下操作检查登录数据://Create a new function named fetch; function fetch($sql = false,$bind = false,$obj = false) { //Prepare The SQL Query; $query = Connect()->prepare($sql); //Execute Binded Query; $query->execute($bind); //While Fetching Results; while($result = $query->fetch(PDO::FETCH_ASSOC)) { //Add a row to the results respectiveley; $row[] = $result; } //If there are no rows; if(!empty($row)) { //Make it an object; $row = ($obj)? (object) $row : $row; } else { //Else row is false; $row = false; } //If no errors happened Make $row true; return $row; } //Create a new function named user_login; function user_login($username = false, $password = false) { //Fetch for the username and password applied; $st = fetch("SELECT username,password,email,image FROM users WHERE username = :username",array(":username"=>$username)); //If a row was found continue if($st != 0) { $storedhash = $st[0]['password']; if (password_verify($password, $storedhash)) { //Set a new username session and set it the username; $_SESSION['username'] = $username; $_SESSION['email'] = $st[0]['email']; $_SESSION['image'] = $st[0]['image']; if($username == 'admin') { $_SESSION['role'] = 'admin'; } else { $_SESSION['role'] = 'user'; } } } //If no errors happened Make the $valid true; return true; $dontaddtry = true; }

如果是正确的详细信息,则会保存会话。否则返回false。

这就像我在所有浏览器中说的那样,但Safari。我在这里找到的其他问题没有帮助。它们都是常见的错误,例如缺少exit(),逗号,e.t.c。

我很感激帮助!

0 个答案:

没有答案