1

I've created a React App to my existing php page which is using session to store userid. The session is set by a normal .php login page, but when I try to call API call who access the session, it appears it's not set.

Is react apps inside its own 'environment' and is it required to use tokens?

I'm confused..

EDIT: solved it by this question from om a different thread: https://stackoverflow.com/a/44111668/3010171

by including

credentials: 'same-origin'

in the header of the request.

Christian Moen
  • 1,253
  • 2
  • 17
  • 31

2 Answers2

0

solved it by this question from om a different thread: https://stackoverflow.com/a/44111668/3010171

by including

credentials: 'same-origin'

in the header of the request.

Christian Moen
  • 1,253
  • 2
  • 17
  • 31
-1

It's two different things. PHP works on server-side and React is client-side.

enter image description here

As you can see, WebServer returns a HTML content to a Client. ReactJS works in web browser. If you want to receive some datas from server, you can see this tutorial https://www.youtube.com/watch?v=Y4NHqDp88lA

Mateus Gabi
  • 99
  • 1
  • 2
  • I do not think you understood the question. The client calls a request to an API which is using $_SESSION['userid']. Any cookie the browser has is ignored within the react framework.. – Christian Moen Apr 01 '18 at 00:41
  • I see... @ChristianMoen can you show me a simple example? – Mateus Gabi Apr 01 '18 at 02:23