1 (edited by Loa 2007-04-26 14:50)

Topic: Get guest info from $pun_user

Heya!

I have a external page that I want to protect with punbb user auth.
So I included the common.php and all.

But when I echo the info from the pun_user I get the guest user info all the time. I'm logged in on the forum but can't access my own info.

Cheers Carl!

2

Re: Get guest info from $pun_user

What is the code you are using ?
if you echo $pun_user you won't get anything you have to get the correct array of $pun_user[]

3

Re: Get guest info from $pun_user

I echo $pun_user['is_guest'] and get 1 and when I echo $pun_user['username'] I get Guest... so I get the guest account information ..but Im logged in on the forum..

4

Re: Get guest info from $pun_user

You have to include the config file on your php file I believe. That is what I do.

But I don't use is_guest, so I don't know if that is the problem or not. I just use  if ($pun_user['username'] == 'Guest') {

It's more hassle, but it's worth a try smile

Re: Get guest info from $pun_user

is_guest is the correct way to evaluate it

carlodin: So you're logged in to the forums at the time? Is the domain of the site the same? Did you set a path in config.php for the cookie that this external file isn't in?

6 (edited by Loa 2007-05-13 16:20)

Re: Get guest info from $pun_user

Hey!

Sorry for the late reply but I thought I wouldnt get any responds..

Well Smartys its not the same domain address.. I discovered that it was the issue (why I searched up this post again)

So .. the forum is beneath http://forum.example.com and my file where I need the user info is located beneath http://news.example.com.

You said anything about cookie.. is it possible to fix on a good way without creating a security risk?

EDIT:

The path in config.php is set to '/'.

Cheers Carl!

Re: Get guest info from $pun_user

OK, so in config.php you need to set the cookie_domain to .example.com
That way, the cookie will work over all subdomains of example.com

8 (edited by Loa 2007-05-14 22:03)

Re: Get guest info from $pun_user

I tried to set it to '.example.com'.

It works for http://forum.example.com (the forum) but not for my http://www.example.com.

http://www.example.com/index.php:

<?php
define('PUN_ROOT', '../forum/');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';

echo $pun_user['username'];
?>

http://www.example.com still shows Guest.


EDIT:

its started to working ... didnt work with a certain domain that I only used for dev.. but worked fine for the real domain names.

Thanks alot!