Declare variable for sitewide use

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
User avatar
Strider64
php-forum Active User
php-forum Active User
Posts: 290
Joined: Sat Mar 23, 2013 8:24 am

Re: Declare variable for sitewide use

Post by Strider64 » Wed Jun 05, 2013 9:05 am

This could be an utilities.inc.php file for example

Code: Select all

session_start();

// Check $varRegionCode in session:
$varRegionCode = (isset($_SESSION['varRegionCode'])) ? $_SESSION['varRegionCode'] : NULL;
check_settings.php

Code: Select all

// Need the utilities file:
require('includes/utilities.inc.php');
$_SESSION['varRegionCode'] = 'SEVA';
check_settings_2.php

Code: Select all

// Need the utilities file:
require('includes/utilities.inc.php');
if ($varRegionCode) {
      echo "The region code variable is set to " . $varRegionCode . ".";
} else {
     $_SESSION['varRegionCode'] = 'DMKZ';
}

Maybe do something like the above?
I just wanted to add NEVER put any sensitive data in $_SESSION like passwords for example.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest