RSS Feed for This PostCurrent Article

How many ways can we get the value of current session id?

session_id() returns the session id for the current session.

Trackback URL

  1. 2 Comment(s)

  2. By Milena Dimitrova on Mar 30, 2008 | Reply

    <?php
    session_start();
    // variant 1 to find session ID
    echo session_id();
    echo ”;

    // variant 2 to find session ID
    $session_ccokies=explode(’;',$_SERVER['HTTP_COOKIE']);
    foreach($session_ccokies as $cookie)
    {
    list($cookie_name, $cookie_value)=explode(’=',$cookie);
    if (trim($cookie_name)==’PHPSESSID’)
    {
    $session_id=$cookie_value;
    }

    }

    echo $session_id;
    ?>

  3. By lizzeelike on Aug 13, 2008 | Reply

    thanks for the 2nd variant. its very nice of u that, u post a easily understandable code instated of complex explanation. its very helpful for beginner’s

Post a Comment