Jump to content

Finding out cookie information


Mutley

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?
Link to comment
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]
Link to comment
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?
Link to comment
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]
Link to comment
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. 
Link to comment
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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.