15 years on The Web
miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Specific miniBB Support Forums / Specific /   

Retreaving user name

Author LeeuW
#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]);
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
#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
#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:


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
#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:

You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.

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
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB