Jump to content

Simple Session Question


phpretard

Recommended Posts

The first version only works when register globals are on, has been depreciated since php 4.2 in the year 2002, and has been completely eliminated in php6.

 

The second version should be used in all current and new code. The second version also works since PHP 4.1.0, regardless of the register globals setting.

Thank you for clearing that up.

 

With that info in place...

 

What do you suggest I use to replace this statement below and how should I echo the var?

 

I would ultimatly like to echo the var on evry page...but it isn't happening unless I set it on every page.

 

If this question is deeper then I think can you point me towards a good tutorial in these regards?

 


if(session_is_registered(FirstName)){

echo "?????";

}

 

Thank you fir you help with this.

When you use sessions, make sure you call the session_start() function on every page that uses sessions, eg:

<?php
session_start();

// your code

?>

Also to check if a session variable exists, use isset:

if(isset($_SESSION['FirstName']))
{
    echo '$_SESSION[\'FirstName\'] exists';
}
else
{
    echo '$_SESSION[\'FirstName\'] does not exist';
}

 

session_is_registered is also depreciated I believe.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.