Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi all,
I have defined a user defined  function which is located in a config.php include file that is the first file in every page:

 

function set_cms()
{
    $set_cms_site = 'Gallery';
    
    setcookie ('set_cms_site', $set_cms_site);
    
    echo '<span class="banner_colour">' . $_COOKIE['set_cms_site'] . '</span>';
    
}

 

I then call it as follows:

 

echo'
<div id="page_heading">
<h2 class="centre_text">';
//Call function to display the CMS site that has been logged into
set_cms();

echo'
: Add new category</h2>
</div>
';

 

When I load the page it comes up with 'Undefined index: set_cms_site '.

 

However when I reload the page it works. I would guess that I'm doing something in the wrong order and the whole process isn't loading the first time but it is the second time.

 

Thanks

Paul

 

Link to comment
Share on other sites

Hi all,

Ignore this. The cookie isn't set until the function is called. It won't work the first time. Just realised when I tried to write a second function using the same cookie and realised that cookie is only available when the first function is called.

 

Sorry

Paul

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...