Jump to content

Archived

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

Mutley

Finding out cookie information

Recommended Posts

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?

Share this post


Link to post
Share on other sites
You can detect your own cookies when logged in on your own system and thereby determ keys
[code]

<!-- Find cookies -->

<?php

print "<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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
[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 7

However I found this documentation, maybe it is useful?
http://www.phpbb.com/kb/article.php?article_id=143

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.