passing session id via url

前端 未结 5 1392
逝去的感伤
逝去的感伤 2020-12-03 23:26

I\'m trying to get my script to use url session id instead of cookies. The following page is not picking up the variable in the url as the session id. I must be missing some

5条回答
  •  孤街浪徒
    2020-12-04 00:04

    It looks like you just need to call session_start() on the second page.

    From the docs:

    session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.

    EDIT:

    That said, you could also try manually grabbing the session id from the query string. On the second page you'd need to do something like:

    ini_set("session.use_cookies",0);
    ini_set("session.use_trans_sid",1);
    session_id($_GET['session_id']);
    print_r($_SESSION);
    print(session_id());
    

    Note that the session_id() function will set the id if you pass it the id as a parameter.

提交回复
热议问题