This usually Warning: Illegal string offset ...means that you are trying to access a string as an array .
You are currently setting $_SESSION['errors']to an associative array with two elements messageand variables. I believe that you are trying to create an array with several errors, each of which has messageand variables.
This type of configuration should be performed:
...
$_SESSION['errors'] = array();
if ($count > 0) {
$_SESSION['errors'][] = array(
'message' = > 'User Already Exists',
'variables' = > array(
'name' = > $_POST['name'],
'password' = > $_POST['password'],
),
);
header('location: '.URL.'user/registration');
exit;
}
...
Empty square brackets add a new element to the array:
$myArray[] = $myNewElement;
:
$_SESSION['errors'][] = array(
'message' = > 'Error two',
'variables' = > array(...),
);
$_SESSION['errors'][] = array(
'message' = > 'Error three',
'variables' = > array(...),
);