Jump to content


Photo

Finding out cookie information


  • Please log in to reply
8 replies to this topic

#1 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 06 October 2006 - 09:41 PM

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?
~ Mutley.

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 07 October 2006 - 06:28 AM

You can detect your own cookies when logged in on your own system and thereby determ keys

<!-- 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


#3 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 07 October 2006 - 08:00 AM

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?

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);


Or something like that?

Then for each member page:


ob_start();
include('config.php');
if($logged[username]) {
// content goes here
} else {
You need to be a member
}


I'm still unsure how to check the cookies? Just to see if they are logged in?
~ Mutley.

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 07 October 2006 - 08:07 AM

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?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 07 October 2006 - 08:20 AM

Your probably right, so how do I find out what the sessions are to use them?

This is what was in the cookie:
[phpbb2mysql_data] => a:2:{s:11:\"autologinid\";s:32:\"c6b359b68d9f49720123fd1bd02d0620\";s:6:\"userid\";i:2;}
    [phpbb2mysql_sid] => 7473961c99244cc03f7248a7c7e7cef4

~ Mutley.

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 07 October 2006 - 08:30 AM

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:

foreach($_SESSION as $key => $val) {
  echo "$key : $val <br>";
}

find the session variable name that holds the user's name, and then just check if that session variable isset in your other script. 
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 07 October 2006 - 08:48 AM

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:

foreach($_SESSION as $key => $val) {
  echo "$key : $val <br>";
}

find the session variable name that holds the user's name, and then just check if that session variable isset in your other script. 


Warning: Invalid argument supplied for foreach() on line 7

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


~ Mutley.

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 07 October 2006 - 08:51 AM

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..
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 07 October 2006 - 09:36 AM

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


Whoops, lol, hmm, yeh I should of read the page, that's what I was looking for. Thanks, I'll try it out.
~ Mutley.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users