Re: Conditional session initialization on Auth
| From: | Bertrand Mansion | Date: | Sat, 12 Jul 2003 10:04:12 +0000 |
| Subject: | Re: Conditional session initialization on Auth | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18192@lists.php.net to get a copy of this message | ||
<alan@akbkhome.com> wrote :
> Attached is a patch that adds a flag to $auth->start()
>
> $auth->start(); // same behavour as usual..
> $auth->start(true); // always register the session (eg. same as usual
> behaviour)
>
> $auth->start(false);
>
> will only initiate a session when
> a) the user tries to log in
> b) if there is an existing session (using $_REQUEST[session_name()])
>
> I needed this to enable authentication information to be carried around
> a site which some parts are open, and others secure. - so I call start()
> on all pages, but dont want to generate session data/files for all
> visitors..
While you are at it, I would also suggest another change to the start()
method by adding two paramaters : $userfield, $passfield so that we don't
always have to call our login form fields 'username' and 'password'.
With your changes, start() will become:
function start($regSession = true, $userfield = 'username',
$passfield='password')
I needed this change because I don't have control aver the client
application that is trying to connect to my server and it happens they use
'Username' and 'Password' instead.
Bertrand Mansion
Mamasam