i have a function that echo $_SESSION value in login page and store $_SERVER['REQUEST_URI'] as $_SESSION value on other page and it works fine.
But i need to call redirect_after_login function in all product page so i just added line after redirect_after_login
So my function.php file will look link this
<?php
session_start();
$key = '';
function redirect_after_login($value) {
if (!empty($value)) {
echo $_SESSION['url'];
} else {
echo $_SESSION['url'] = $_SERVER['REQUEST_URI'];
}
}
$activate_finction = $key == true ? 'Yes' : '';
$url = redirect_after_login($activate_finction);
And in login.php i added
$key .= 'login';//calling redirect function with value so it should send session value
if (isset($_POST['submit'])) {
// login function skipped it....
header('location:' . $url);
exit;
} else {
$error[] = 'Wrong username or password or your account has not been activated.';
}
}
Since $key .= 'login'; has value
$activate_finction = $key == true ? 'Yes' : '';
$url = redirect_after_login($activate_finction);
Function is now called with ==true so i should receive stored value but still i get requested_url
My problem is
in all page i get $_SESSION['url'] = $_SERVER['REQUEST_URI']; this value.
How do i get session value login.php and in all product pages function should store requested_url as session value.