miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Specific miniBB Support Forums / Specific /   

Retreaving user name

Author LeeuW
Registered
#1 | Posted: 27 Aug 2006 15:19 
I have miniBB in a subdirecotory of my site.

I use the function below to read out the usernamen from the session.

function getUserName(){
if(isset($_SESSION['minimalistBBSession'])) {
$cookievalue=explode ('|', $_SESSION['minimalistBBSession']);
if(!ini_get('magic_quotes_gpc')) $cookievalue[0]=addslashes($cookievalue[0]);
$cookievalue[1]=str_replace("'",'',$cookievalue[1]);
}
else $cookievalue=array('','','');
return $cookievalue[0];
}

But it only works inside the miniBB dir, how can i make it work outside that dir?

Author Paul
Lead Developer
#2 | Posted: 28 Aug 2006 08:27 
Probably, your server's configuration allows read the session variables only from the folder, where they've been set up. There is no solution except that you need to change configuration in the server itself.

Author LeeuW
Registered
#3 | Posted: 30 Aug 2006 12:29 
session.cookie_path = /
I guess that means that is not the problem.

Author Paul
Lead Developer
#4 | Posted: 30 Aug 2006 17:04 
So, why you are reading $_SESSION variable? By default, miniBB uses cookies (and we recommend to disable sessions, since using cookies is enough). It only will work if you have $useSessions=TRUE; in setup_options.php. Do you have this setting enabled? Or you can try to disable it and try with $_COOKIE... the same way as it is in bb_cookie.php

Author hackersapien
Registered
#5 | Posted: 4 Sep 2006 08:00 
I'm also having a similar problem as LeeuW, my forum is located in subfolder /forum, when I try and access the cookies set by the forum in the main site folder it comes back blank, I 've tried using:

print_r($_COOKIE);

But still it comes back empty, If I change the cookie path to "/" the login in the forum refuses to work completely.

Any Ideas on how to solve this?

Author hackersapien
Registered
#6 | Posted: 4 Sep 2006 08:45 
I solved the problem by modifying the setMyCookie() method in the bb_cookie.php file, I added the following code while stil retaining the existing code:

setcookie($GLOBALS['cookiename'], $userName.'|'.$userPass.'|'.$userExpTime, $GLOBALS['cookieexptime'], '/', $GLOBALS['cookiedomain'], $GLOBALS['cookiesecure']);

This sets a cookie that is accessible from the "/" path, I can now access the cookie from whichever directory I chose.

I also had to modify the deleteMyCookie() method to destroy the cookie:

setcookie($GLOBALS['cookiename'], '', (time()-2592000), '/', $GLOBALS['cookiedomain'], $GLOBALS['cookiesecure']);

Author Paul
Lead Developer
#7 | Posted: 4 Sep 2006 09:26 
Don't know why you needed to edit these functions, if $cookiepath setting is given in setup_options.php ;-)

Specific miniBB Support Forums / Specific / Retreaving user name Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB