Re: [GENERAL] passing variables in PHP3

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: sheilabel(at)hotmail(dot)com
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] passing variables in PHP3
Date: 2000-02-28 01:33:50
Message-ID: 20000228103350U.t-ishii@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I've written an application for the web that asks users for their
> id and password, checks the database and if they are legit
> takes them to a page. Now I'm using the PHP_AUTH_USER variable
> to identify the user and I need that information from one
> file to another. How do I do that ? I tried storing it in a
> variable and sending it along an with html anchor but that is
> not a neat way of doing it since every time I need the value of
> that variable the user has to click on an image and another problem
> with that is the user id will show up in the url and I don't want
> that security risk.
> So my question is how do I store the value of PHP_AUTH_USER for
> a specific user and access it from many PHP3 files ?

First, you should not set PHP_AUTH_USER by yourself. It is
automazically set by PHP itself, if properly used(see sample code
below). Second, you do not need to embed the variable into the anchor.
Once the authentication is done for the directory where your login
page lives, the next page will automatically inherit PHP_AUTH_USER
variable.
--
Tatsuo Ishii

if (!$PHP_AUTH_USER) {
Header("WWW-authenticate: basic realm=\"php authentication example\"");
Header("HTTP/1.0 401 Unauthorized");
print("User authentication is canceld");
exit;
} else {
// do whatever authentication method you like.
// then set $auth to true if it succeeded.
if ($auth == false) {
Header("HTTP/1.0 401 Unauthorized");
print("User authentication is failed");
exit;
}
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Charles Tassell 2000-02-28 02:00:24 Re: [GENERAL] passing variables in PHP3
Previous Message Gary MacMinn 2000-02-28 01:04:40 Re: [GENERAL] passing variables in PHP3