Ik heb een bestand genaamd functions.php en dat ziet er ongeveer zo uit:
<?php
/*Heel wat andere regels*/
class USER {
public $test = "hoi";
function authenticate(){
ini_set('session.cookie_domain', '.example.com');
session_start();
if (!isset($_SESSION['username'])) {
header("Location: https://example.com");
exit();
} else {
if ($_SESSION['school'] != "correcteschool") {
$school = $_SESSION['school'];
if ($school != "admin") {
$url = "https://" . $school . ".example.com";
header("Location: $url");
}
}
}
$username = $_SESSION['username'];
$school = $_SESSION['school'];
}
}
/*De rest van de code*/
?>
Dit is mijn index.php
<?php
include "includes/functions.php";
$user = new USER();
$user->authenticate();
echo $school;
?>
er gebeurd niks (geen school in ieder geval)
als ik de echo tag in de functie zet, en de functie "aanroep" werkt het wel.
Als ik de test variabele wil printen kan ik dit doen:
<?php
echo $user->test;
?>
Kan iemand mij helpen?
Ik heb de adressen veranderd omwille van privacyredenen