I created a redirect page in PHP that whenever some one visits that page, it will add a cookie in browser and redirect user to some other page: ex: google.com
.
To do that, I have used javascript to redirect but problem is that when I extract my url it doesn't show google.com
. During extraction it shows the same page's information then I use php header()
for redirection and it shows me the google.com
info.
Now I need help to make this code work with cookie and header.
Code:
<?php
header("location: https://www.google.com");
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Redirecting...</title>
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
createCookie("karachi","testing",100);
</script>
</head>
<body>
</body>
</html>';
?>