Jump to content

Sessions issue


xadmin

Recommended Posts

Okay, I working on a script that through a controller .php processes login,registration,logout, verification ect.

 

the login controller script looks something like this.

 

      private function procLogin () {

 

           if ($this->pAuth->login($this->pForm))

       {

           $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername);

           if ($aUserInfo['userlevel'] == 3 || $aUserInfo['userlevel'] == 9)

       {

           functions::echoLocate('Log in successful.', 'http://mobile.mysite.com/privileged.php');

       }

  else

       {

           functions::echoLocate('Log in successful.', 'http://mobile.mysite.com/berry.php');

       }

       }

  else

       {

           $this->pForm->rememberData();

           functions::echoLocate('Log in failed.', 'http://mobile.mysite.com/failed.php');

       }

       }

 

the problem is when I complete the login forum, using my admin account (level 9) or a level 3 test account.

 

in both cases i'm directed to berry.php

 

this is not supposed to happen.

 

does anyone know another way to write the following in a way that works, as I get zero script errors.

 

           $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername);

           if ($aUserInfo['userlevel'] == 3 || $aUserInfo['userlevel'] == 9)

 

 

Link to comment
https://forums.phpfreaks.com/topic/117441-sessions-issue/
Share on other sites

I'm assuming you meant like this

 

          $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername); die($aUserInfo['userlevel']);

          if ($aUserInfo['userlevel'] === 3 || $aUserInfo['userlevel'] === 9)

 

The result of adding die($aUserInfo['userlevel']);

 

is that I get a blank white screen unpon successful login.

 

 

Link to comment
https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604108
Share on other sites

checked my sessions API and this is what is responsible for populatin the active database

 

/**

* Adds the specified user to the database as active, and

* populates the _userInfo array for use by {@link whoAmI()}

*

* @access private

* @param  string $szUsername  The user to add as active

* @param  string $szIP        The users IP address

* @param  string $szUserAgent The user agent string that they signed in with

* @return void

*/

 

private function _addMember ($szUsername, $szIP, $szUserAgent) {

 

$this->_userInfo = $this->pDatabase->getUserInfo($szUsername);

 

if ($this->_userInfo !== FALSE)

{

$this->pDatabase->addMember($szUsername, $szIP, $szUserAgent);

}

 

}

 

still cant figure out why data being recieved by $aUserInfo['userlevel']

Link to comment
https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604244
Share on other sites

this is how my api is configured for returning user info

 

/**

* Returns an array of information for the current user,

* including their username, email and access level.

*

* @access public

* @param string $szUsername The username we need information on

* @return mixed An associate array containing the result, (bool) false if nothing is found

*/

 

public function getUserInfo ($szUsername)

{

$q = sprintf("SELECT `username`, `email`, `userlevel`, `registered_on`, `user_last_active`, `verified` FROM `".TBL_PREFIX."users` WHERE username = '%s' LIMIT 1", mysql_real_escape_string($szUsername));

$pResult = mysql_query($q);

 

return (mysql_num_rows($pResult) == 1) ? mysql_fetch_assoc($pResult) : FALSE;

}

Link to comment
https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604495
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.