[pmwiki-users] Determine whether the visitor is logged in

Patrick R. Michaud pmichaud at pobox.com
Thu May 5 08:09:53 CDT 2005

On Thu, May 05, 2005 at 02:27:18PM +0200, Peter Brink wrote:
> Joachim Durchholz skrev:
> >What's the best way to find out whether the visitor is authenticated?
> >I need to check that from PHP code. (The basic idea is that there's no 
> >need for email obfuscation if the user has given a password. Mail 
> >harvesters wouldn't bother to crack passwords or create an account just 
> >to get at a few hundred addresses.)
> >
> I'd like to know this too. For example, I'd like to be able to adapt the 
> items in an action list based on whether the user is logged in or not. 
> Using the new (since beta29) authentification system I'm able to test 
> whether or not the user is logged in as admin. I'd like to be able to 
> write a conditional markup such as for example: (:if isauthenticated 
> true:) Blah, Blah (:ifend:).

The markup

    (:if authid:) Blah, Blah (:ifend:)

should work.

The answer to Jo's question is slightly harder, because the authorization
name ($AuthId) isn't set until a page has been read via RetrieveAuthPage.
So, one could do something like:

    if ($AuthId == '')  RetrieveAuthPage('PmWiki', 'read', false); 
    if ($AuthId > '') { 


More information about the pmwiki-users mailing list