}
// Set cookie when default refid > 0
- if (!isSessionVariableSet('refid') || (!isValidUserId(getReferalId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) {
+ if ((!isSessionVariableSet('refid')) || (!isValidUserId(getReferalId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) {
// Default is not found
$found = false;
// Set cookie
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferalId() . ') #1');
setSession('refid', getReferalId());
- } elseif (!isReferalIdValid()) {
+ } elseif ((!isReferalIdValid()) || (!fetchUserData(getReferalId()))) {
// Not valid!
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not valid referal id (' . getReferalId() . '), setting NULL in session');
+ setReferalId(NULL);
setSession('refid', NULL);
- } elseif ((!isSessionVariableSet('refid')) && (isValidUserId(getReferalId()))) {
+ } else {
// Set it from GLOBALS array in session
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferalId() . ') #2');
setSession('refid', getReferalId());