how to get session variables using session id

$_SESSION is what you are looking for. Remember to call session_start() first. See http://php.net/session.examples.basic


var_dump($_SESSION); will show you the contents of the current session, you can then access the values just like you would on a normal array.


You can check all session value using this one..

print_r($_SESSION);

According to php.net: There are several ways to leak an existing session id to third parties. A leaked session id enables the third party to access all resources which are associated with a specific id. First, URLs carrying session ids. If you link to an external site, the URL including the session id might be stored in the external site's referrer logs. Second, a more active attacker might listen to your network traffic. If it is not encrypted, session ids will flow in plain text over the network. The solution here is to implement SSL on your server and make it mandatory for users.

This begs the question, how do you have the session ID but unable to access the script?

Regardless, you would need to set the session ID and then start it...then access the data.

session_id($whatever_id_you_have);
session_start();
echo $_SESSION['somekey'];

Tags:

Php

Session