PHP SID is not displayed

I cannot get my SID to work ...

<?php
session_start();
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';?>

      

the SID number is not displayed but session_id is working not sure if I am missing something. Thnks

+3


source to share


4 answers


You need session.use_trans_sid

to enable it for PHP to accept a session ID passed in either GET or POST.



+4


source


The SID constant will show an empty string if a cookie named session.name was detected by the PHP file . See the man page . This means that the SID will only contain the usable string before the session cookie is sent to the browser.



This also means that if the browser refuses cookies, the persistent SID will work. Provided seeion.use_trans_id is included as Gumbo said.

+8


source


page 1:

<?php
    session_start();
    // why use it in a url?
    echo session_id();
    echo '<br /><a href=page2.php target=_blank>page 2</a>';
?>

      

page 2:

<?php
    session_start();
    // page 2
    echo session_id();
    echo '<br> <br> on page 2 ';
?>

      

+1


source


Avoid omitting session IDs in URLs whenever possible; for cases where it is needed (such as when the client rejects the session cookie), have the built-in url rewriters modify the HTML.

Passing session IDs in URLs means you expose implementation details in URLs. Purist views aside, this can lead to practical problems with users copying and sharing URLs that contain session information, inadvertently exposing their sessions to friends or anyone else they share with.

0


source







All Articles