Mutley Posted October 6, 2006 Share Posted October 6, 2006 I'm wanting to make certain data on custom pages to be shown or not shown depending on if my users are logged into the PHPBB2 forum.I guess all I need is to confirm their cookie data, how do I find out what the cookies are that are used? And the data inside them to help me show areas on pages? Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/ Share on other sites More sharing options...
alpine Posted October 7, 2006 Share Posted October 7, 2006 You can detect your own cookies when logged in on your own system and thereby determ keys[code]<!-- Find cookies --><?phpprint "<pre>";print_r($_COOKIE);print "</pre>";?><!-- Outputs -->Array( [PHPSESSID] => 93aecbf189f91b972145dcf25a42610a [user] => blabla [ip] => 88.216.180.88 [code] => 923hdhuewh934y39euhudhwd)<!-- use information now that you know the key names --><?php$user = $_COOKIE['user'];?>[/code]Otherwise, use the third party scripts section for help on phpBB: http://www.phpfreaks.com/forums/index.php/board,34.0.html[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105399 Share on other sites More sharing options...
Mutley Posted October 7, 2006 Author Share Posted October 7, 2006 Now I have the cookie information, I want to use this to make the member only content. So I need a config file to check the cookies? All I want to do is check if they are logged in, I don't care what level, just as long as they a member.So in the config.php file what would I need?[code=php:0]ob_start();$conn = mysql_connect("localhost","username","password");mysql_select_db(database) or die(mysql_error());$logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE'");$logged = mysql_fetch_array($logged);[/code]Or something like that?Then for each member page:[code=php:0]ob_start();include('config.php');if($logged[username]) {// content goes here} else {You need to be a member}[/code]I'm still unsure how to check the cookies? Just to see if they are logged in? Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105418 Share on other sites More sharing options...
.josh Posted October 7, 2006 Share Posted October 7, 2006 does phpbb use cookies to determine if someone is logged in? i thought they used sessions. shouldn't you be looking for a session variable being set? Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105420 Share on other sites More sharing options...
Mutley Posted October 7, 2006 Author Share Posted October 7, 2006 Your probably right, so how do I find out what the sessions are to use them?This is what was in the cookie:[code][phpbb2mysql_data] => a:2:{s:11:\"autologinid\";s:32:\"c6b359b68d9f49720123fd1bd02d0620\";s:6:\"userid\";i:2;} [phpbb2mysql_sid] => 7473961c99244cc03f7248a7c7e7cef4[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105422 Share on other sites More sharing options...
.josh Posted October 7, 2006 Share Posted October 7, 2006 i bet phpbb's documentation might tell you where to look. Or else, you could just add a little codeblock to your phpbb board page somewhere inside the logged-in phase, that in essence, basically does this:[code]foreach($_SESSION as $key => $val) { echo "$key : $val <br>";}[/code]find the session variable name that holds the user's name, and then just check if that session variable isset in your other script. Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105424 Share on other sites More sharing options...
Mutley Posted October 7, 2006 Author Share Posted October 7, 2006 [quote author=Crayon Violent link=topic=110738.msg448423#msg448423 date=1160209805]i bet phpbb's documentation might tell you where to look. Or else, you could just add a little codeblock to your phpbb board page somewhere inside the logged-in phase, that in essence, basically does this:[code]foreach($_SESSION as $key => $val) { echo "$key : $val <br>";}[/code]find the session variable name that holds the user's name, and then just check if that session variable isset in your other script. [/quote]Warning: Invalid argument supplied for foreach() on line 7However I found this documentation, maybe it is useful?http://www.phpbb.com/kb/article.php?article_id=143 Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105433 Share on other sites More sharing options...
.josh Posted October 7, 2006 Share Posted October 7, 2006 okay i'm really tired, so maybe i'm just not reading that link right..but it looks to me like phpbb script relies on register_globals being ON??? edit: or, well, maybe not. It kinda looks like they..well, in any case, that link looks like it shows you how to do exactly what you are asking.. Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105434 Share on other sites More sharing options...
Mutley Posted October 7, 2006 Author Share Posted October 7, 2006 [quote author=Crayon Violent link=topic=110738.msg448433#msg448433 date=1160211111]edit: or, well, maybe not. It kinda looks like they..well, in any case, that link looks like it shows you how to do exactly what you are asking..[/quote]Whoops, lol, hmm, yeh I should of read the page, that's what I was looking for. Thanks, I'll try it out. Quote Link to comment https://forums.phpfreaks.com/topic/23218-finding-out-cookie-information/#findComment-105447 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.