Forum OpenACS Development: Re: Problem with acs_user::get_element

Collapse
Posted by Amruta Lakade on
Hi Gustaf,
Thanks for the reply.

I am using the api to know the name of logged-in user only.
At the moment of calling the api if i don't know the user_id then how should I provide it?

-Amruta

Collapse
Posted by Gustaf Neumann on
One can get the user_id of the current user via "ad_conn user_id". If the result of "ad_conn user_id" is 0, no user is currently logged-in in this thread.
Collapse
Posted by Mark Aufflick on
This is not *quite* correct. There are two user_id values available from ad_conn: user_id and untrusted_user_id

The difference in behaviour is this:


                    no user     user logged in    user logged in
                    logged_in   and not expired   but expired
user_id                0            the id             0
untrusted_user_id      0            the id          the id

It's important to know the difference because otherwise your users will have the confusion of the "logged in as..." showing that they are logged in, but your code relying solely on ad_conn user_id behaving as though they are not logged in.

Just thought it worth clarifying.