douhuan1380
2018-03-31 20:18
浏览 93

在php页面上反应app; React无权访问Session

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 questin from om a different thread: https://stackoverflow.com/a/44111668/3010171

图片转代码服务由CSDN问答提供 功能建议

我已经在我现有的php页面创建了一个React App,它使用session来存储 userid 。 该会话由一个普通的.php登录页面设置,但是当我尝试调用访问会话的API调用时,它似乎没有设置。

反应应用程序是否位于其自己的环境中 '并且是否需要使用令牌?

我很困惑..

编辑:通过这个来自不同线程的任务来解决它: https://stackoverflow.com/a/44111668/3010171

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doulan9419 2018-03-31 23:25

    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

    打赏 评论

相关推荐 更多相似问题