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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.