0

PHPSESSID is blank when I

echo $PHPSESSID

But in php.ini file I have added

session.name = PHPSESSID

I am using PHP 5.4.35 .What is the problem here?

Salman A
  • 262,204
  • 82
  • 430
  • 521
Joy Das
  • 85
  • 2
  • 13

3 Answers3

4

You should use $_COOKIE['PHPSESSID'], for example:

session_start();
echo session_id();
print $_COOKIE['PHPSESSID'];

will print you Session's ID twice, one by echo session_id(); and second by print $_COOKIE['PHPSESSID'];

KennyPowers
  • 4,925
  • 8
  • 36
  • 51
3

Use the session_id function. This retrieves the value of the session id regardless of the name that was used to create the session (cookie or otherwise).

If you are interested in getting the name, you could use use ini_get("session.name").

Salman A
  • 262,204
  • 82
  • 430
  • 521
2

$PHPSESSID is not correct. PHPSESSID is an index of array $_COOKIE[]. Example:

echo $_COOKIE["PHPSESSID"];

This cookie starts when you start a session.

Nader
  • 1,120
  • 1
  • 9
  • 22