Detect authenticated user id of a browser

Biplab Karki Posted in Technical Support 3 years ago

How may I detect the user id of an authenticated user of a browser? I am in need of creating some API or find some browser-based way to find the user id of the authenticated user in a browser. Any easy way for it?

Replies
Indonesian Arsalan Shah Replied 3 years ago

If you are developer then you should know the answer. We can not answer on behalf of others developers. It depends on a person who is going to program your use case.

np Biplab Karki Replied 3 years ago

Would it be possible to create my own API to find the logged-in user id?

Indonesian Arsalan Shah Replied 3 years ago

Well if you are on same session and browser server where OSSN is installed can get user id like

$id = ossn_loggedin_user()->guid;

But if you asking is there any way to find loggedin user id using API then it is not possible :)
You are planning to allow user to post using API for user that is loggedin you need to use user_auth API and some how you need to store in your API cookie somewhere securely if user is loggedin via API and its success.

  1. User tries to login using your app that uses API
  2. You get response of success or failure
  3. If success you know user succeed to login then
  4. You need to securly managed session on your app and store that user email/id in your cookie or somewhere secure inside app.
np Biplab Karki Replied 3 years ago

I am building a new image tool under the subdomain (c.web.com) of my social media (web.com). c.web.com must be able to post the image created via the tool to social media using the web service API only when any user of the browser is authenticated. To post it using API, I need the user id of the authenticated user.

German Michael Zülsdorff Replied 3 years ago

Perhaps you can give a little more insight on the workflow you have in mind?
I mean, the server knows best if a user IS authenticated or not and would deliver less/more html/script accordingly.
So why should the browser have to 'know' that, too?