Topic: using punbb session/cookies on my own website..

i want to use the punbb session on my own page or using the same session...

for example..

i have a login form on my page www.mysite.com where my punbb forum url is www.mysite.com/forum.. so how can i use the same session and also the same database for username and password?... can anybody help me please?? ..

Re: using punbb session/cookies on my own website..

I think you can if you modify a bit your login.php smile

French PunBB Support Forum : http://punbb-fr.ircme.net

Re: using punbb session/cookies on my own website..

can u brief me roughly... i need an idea..

4 (edited by Xiutecutli 2004-10-23 17:04)

Re: using punbb session/cookies on my own website..

Hum, if you want you use the cookie of punbb (it use a cookie, is'nt it ?) to log into your website by a form like that :

<form method="post" action="login.php?action=in" id="login" onsubmit="return process_form(this)">
    <input type="hidden" name="form_sent" value="1">
    <input type="hidden" name="redirect_url" value="http://you/index.php">
    <table class="punmain" cellspacing="1" cellpadding="4">
        <tr class="punhead">
            <td class="punhead" colspan="2">Connexion</td>
        </tr>

        <tr>
            <td class="puncon1right" style="width: 140px; white-space: nowrap"><b>Nom d'utilisateur</b>  </td>
            <td class="puncon2"> <input type="text" name="req_username" size="25" maxlength="25"></td>
        </tr>
        <tr>
            <td class="puncon1right" style="width: 140px; white-space: nowrap"><b>Mot de passe</b>  </td>
            <td class="puncon2"> <input type="password" name="req_password" size="16" maxlength="16"></td>
        </tr>

        <tr>
            <td class="puncon1right" style="width: 140px; white-space: nowrap">Actions  </td>
            <td class="puncon2">
                <br>  <input type="submit" name="login" value="Connexion"><br><br>
                 <a href="register.php">Toujours pas enregistré?</a><br>
                 <a href="login.php?action=forget">Mot-de-passe perdu?</a><br><br>
            </td>

        </tr>
    </table>
</form>

pointing on your login.php

The Javascript fonction is

function process_form(theform)
{
    var element_names = new Object()
    element_names["req_username"] = "Nom d\'utilisateur"
    element_names["req_password"] = "Mot de passe"

    // Check for required elements
    if (document.images) {
        for (i = 0; i < theform.length; ++i) {
            if (theform.elements[i].name.substring(0, 4) == "req_") {
                if ((theform.elements[i].type=="text" || theform.elements[i].type=="textarea" || theform.elements[i].type=="password" || theform.elements[i].type=="file") && theform.elements[i].value=='') {
                    alert("\"" + element_names[theform.elements[i].name] + "\" doit être ecrit")
                    return false
                }
            }
        }
    }

    // Disable any submit buttons we find
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; ++i) {
            var elem = theform.elements[i]
            if (elem.type.toLowerCase() == "submit")
                elem.disabled = true
        }
        return true
    }

    return true
}
French PunBB Support Forum : http://punbb-fr.ircme.net

5 (edited by infeeneetee 2004-10-24 22:27)

Re: using punbb session/cookies on my own website..

but that was only pointing to the punbb login.php
how can my website detect the cookies??

can the form pointing two pages simultaneously, one to my page and another one to the punbb login.php ???

Re: using punbb session/cookies on my own website..

Don't know :s

Look in the login.php how does punbb register cookies and try to do the same...

French PunBB Support Forum : http://punbb-fr.ircme.net

Re: using punbb session/cookies on my own website..

got it, thanksss!

Re: using punbb session/cookies on my own website..

You're welcome

French PunBB Support Forum : http://punbb-fr.ircme.net

Re: using punbb session/cookies on my own website..

where can i edit punbb cookies setting? ...

Re: using punbb session/cookies on my own website..

infeeneetee wrote:

where can i edit punbb cookies setting? ...

In config.php.

11 (edited by infeeneetee 2004-10-26 12:42)

Re: using punbb session/cookies on my own website..

i want to set cookie for my whole website from config.php setting..

in config.php
$cookie_domain = '';

just leave it like this
or
set it to $cookie_domain = 'mysite.com'; ??

Re: using punbb session/cookies on my own website..

set it to .mysite.com for all subdomains or mysite.com for no subdomain

Re: using punbb session/cookies on my own website..

another question...
i want to echo my cookie username on my own page...

i've tried this
echo $_COOKIE['punbb_cookie'];

but the output is something like this..
a:2:{i:0;s:11:\"username\";i:1;s:40:\"2fe439007ad13f3f4d7cfd088e88a19bcf47db8b\";}

Re: using punbb session/cookies on my own website..

$cookie['username']

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: using punbb session/cookies on my own website..

i've tried but get an error:-

Notice: Undefined variable: cookie in D:\Web\Apache2\htdocs\Surau\index.php on line 2

Re: using punbb session/cookies on my own website..

What PunBB version?

Are you accessing it from within a function?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: using punbb session/cookies on my own website..

Version: 1.1.5...

nope im not using any even punbb function..
i tried to access it on my own page..

is it possible to do that?

Re: using punbb session/cookies on my own website..

Now I see the problem. In order to get access to any of PunBB's variables (e.g. $cookie), you have to include include/common.php. Something like this:

// First we setup the relative path to the forum root directory
$pun_root = '../forums/';
// Then we include common.php
@include $pun_root.'include/common.php';

// We now have access to all global PunBB variables and functions
"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: using punbb session/cookies on my own website..

thanks rickard, it works!

20 (edited by Chacmool 2004-10-28 07:59)

Re: using punbb session/cookies on my own website..

If you don't want the visit to "count", as in don't update last_visit, I think you'll have to define PUN_QUIET_VISIT:

define('PUN_QUIET_VISIT', 1);

Edit: Do this before including common.php!