php - How to set new session_id when there is cookie passing session_id
大家讲道理
大家讲道理 2017-05-31 10:33:08
0
1
721

App interface development, user data is stored in the session. I thought the app did not have cookies. Now I don’t know that the app has the same cookie mechanism as the browser. The app request interface brings a token (actually it is session_id). Now it is The app passes the session_id through cookie and post, and if the cookie passes the session_id, the sessio data can be obtained by manually setting the session_id. I want to be able to manually set session_id to obtain session data without modifying the server configuration or disabling cookies.

    if($_REQUEST['token']){
        session_destroy();
        if($_REQUEST['token']){
            session_id($_REQUEST['token']);
        }
        session_start();
    }
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
PHPzhong

It should not be native development, but loading webview, otherwise it has nothing to do with cookies, and loading webview is no different from opening it in a browser.
But it should be feasible to add tokens. I feel like you should add the above judgment to the request base class, so that the data passed by the token should be the main one.

if($_REQUEST['token']){
    //session_destroy();//这个不应该存在吧,因为token中的session id很有可能与cookie中的session id是一样的,如果直接销毁了,你指定session_id也没什么作用了,或者先判定下如果不一样再销毁
    if($_REQUEST['token']){    
        session_id($_REQUEST['token']);
    }
    session_start();
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!