I have a validation that, when successful creates a session variable:
if( password_verify($password, $artist_password) ) { // if this is true
// create $_SESSION artist name
$_SESSION['artist_name'] = $artist_name;
return $artist_name;
} else {
echo "Incorrect Password";
}
This validation is initiated by an Ajax request.
If there are errors with the validation, I echo a message. This echoed message is received by the Ajax success method via the data argument.
$.ajax({
url: '../includes/login_validation.php',
type: 'post',
data: inputs,
success: function(data){
$("span#error_msg").html(data);
},
// returns 'Incorrect Password'
My problem is in defining the return response from the PHP file.
For example, when there's an error, the PHP script echoes a message and in turn this response is received and processed through the Ajax success method and placed into a html placeholder.
However, if the SESSION variable is assigned I want to return that data and include it in a redirect.
My question is, how can I discern between an echoed response as the return value and a returned value containing other data (e.g $_SESSION['artist_name']).
And if successful, how can I include it in my redirect so that the redirected page will have access to the session variable.
window.location.href="artistWorkshop.php"; // plus session variable