PHP Classes

login function

Recommend this page to a friend!

      PHPBB 3 Integration class  >  All threads  >  login function  >  (Un) Subscribe thread alerts  
Subject:login function
Summary:Solution to a common login problem
Messages:1
Author:Ezequiel Rabinovich
Date:2009-04-21 06:46:25
 

  1. login function   Reply   Report abuse  
Picture of Ezequiel Rabinovich Ezequiel Rabinovich - 2009-04-21 06:46:25
First of all, thanks a lot for this great class, it really helped me!
I've noticed some people are having problems with the login. I've got it working, however you need to append the sid param to the forum's links. I added $_SID to the global declaration in login and then saved that param inside the user's session to be able to append it to all links to the forum.

Here's my function:

//user_login
public function user_login($phpbb_vars){
global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template, $_SID;
//prezumtia de fail
$phpbb_result = "FAIL";
//general info
$this->init(true);
$user->setup();

if($user->data['is_registered']) {
return;
}
if(!isset($phpbb_vars["autologin"])) $phpbb_vars["autologin"] = true;
if(!isset($phpbb_vars["viewonline"])) $phpbb_vars["viewonline"] = 1;
if(!isset($phpbb_vars["admin"])) $phpbb_vars["admin"] = 0;

//validate and authenticate
$validation = login_db($phpbb_vars["username"], $phpbb_vars["password"]);
$login = $auth->login($phpbb_vars["username"], $phpbb_vars["password"], $phpbb_vars["autologin"], $phpbb_vars["viewonline"], $phpbb_vars["admin"]);
if($validation['status'] == LOGIN_SUCCESS && $login['status'] == LOGIN_SUCCESS) {
$phpbb_result = "SUCCESS";
}
$_SESSION['sid'] = $_SID;
return $phpbb_result;
}

Then my link to the forum is <a href="/phpBB3/?sid=<?php echo $_SESSION['sid']; ?>">Forum</a>

Hope this helps!