On a page on I’m working on, it can be password protected, so a user would have to login before they can see the content. After they login the following code is called:
//In one file
function current_page_url() {
return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
//In Another file
generate_page_cookie();
header('Location: ', current_page_url());
exit;
Which doesn’t work. The following however does:
generate_page_cookie();
header('Location: ', 'http://example.com');
exit;
It seems strange that using a string in the header function works, but a function call within the header function doesn’t.
I think it might have something to do with accessing the $_SERVER variable, but I’m not sure.
Change your
,to., php use.to concat strings.