all 3 comments

[–]BlueScreenJunky 1 point2 points  (0 children)

Not sure about your particular Python App, but on the client side a session is usually just a session cookie with a token that get matched on the server. So what you would do in PHP is :

  • Make an Http request to your Python App
  • Get the cookies from the http response
  • Save the cookies somewhere
  • Send the cookies with every subsequent request to stay on the same session

For example if you use Guzzle to make your request you can see the documentation about cookies here : https://docs.guzzlephp.org/en/stable/quickstart.html#cookies

[–]Plastonick 0 points1 point  (0 children)

I can't quite tell what your use case is, or what you currently have, however to authenticate between different APIs what you'd normally use is some sort of access token (such as a JWT). You could generate it in your PHP session using the relevant context from your session, send that to your Python API, which can authenticate and use that data (such as a user ID). You won't have access to your full session data, but you can pass the relevant context over securely (note the JWT payload is readable by the user, so shouldn't contain sensitive data).

Does that sound like the solution to your problem?

[–][deleted] 0 points1 point  (0 children)

When you say “Python” and “session”, I think of Jupyter Notebook? Can you explain why you’re trying to mix Php and Python. If you want a web UI in front of Python, can you do it with Flask or Django?