I have update the template_redirect hook so that I am able to get the referrer url and save it to session.
function redirect_url() {
if (! is_user_logged_in()) {
$_SESSION['referer_url'] = wp_get_referer();
} else {
session_destroy();
}
}
add_action( 'template_redirect', 'redirect_url' );
I am however now getting a persistent PHP warning that I am unable to get past.
PHP message: PHP Warning: session_destroy(): Trying to destroy uninitialized session in functions.php on line 399" while reading response header from upstream.
Any suggestions here would be great.