dtlh12053 2018-08-03 14:14
浏览 99

在API环境中使用PHP SESSIONS

I have built a cordova mobile application that uses slim framwork to create API's to communciate with my database.

The last step before I finish the project is properly setting up SESSIONS so that a users data is transfered between pages.

At the moment, I have manually set up the session id so it creates one SESSION file in the tmp directory to be accessed. It works fine however this isn't ideal as i wish to have multiple users accessing the app at one time.

Now I'm very unfamilair with how both PHP sessions work and how Slim uses SESSIONS so any help given needs to be in laymans terms.

I have heard about using middleware but again I'm not sure how to use or even install it. Essentially, i just want to be able to carry on using the PHP native SESSIONs i have in place but allow for multiple users to have their own SESSION file.

Currently, I have session_id('TEST) and session_start() in every API function thats being called and this works fine. If i were to take away the session_id and let the application creates sessions for me, every time a API is called, a new session file is being created with a long file name.

Here is my setup and an example of my issue:

enter image description here

enter image description here

Above is what happens when I remove the manual session_id('TEST)

enter image description here

It may be something very simple for you guys so I'm sorry. This is the last step of my work so any assistance with this will be greatly appreciated.

Many Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 随机森林与房贷信用风险模型
    • ¥50 buildozer打包kivy app失败
    • ¥30 在vs2022里运行python代码
    • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
    • ¥15 求解 yolo算法问题
    • ¥15 虚拟机打包apk出现错误
    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备