Start session in external link

Hi,
I would like to check in my php scrip (the script I call with the external app) if the user is signed in.
I run into two problems:

  1. Using session_start() a new session is started instead of the nextcloud session.

  2. Playing inside the nextcloud code using var_dump($_SESSION) the result ist ($_SESSION [“encrypted_session_data”] =“hier is a string with encrypted data”. So if I would be able to start the nextcloud session, I would not be able to read the data.

Has anyone an Idea, how I can verify in my php script, who is the user and if he is actually logged in?
I know, that it is possible to pass the uid in the url, but I want get the user from the session.

Thank you

Michael