
December 18th, 2012, 09:56 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 1
Time spent in forums: 47 m 12 sec
Reputation Power: 0
|
|
|
PHP-General - Php script that will check for cookie,if cookie yes go to url, if no run script
Im trying to create a php script that will check for cookie. If cookie exist it goes to a page. If the cookie does not exist it it will run script.
1. User visits index.php. seeing no cookie runs a script that directs user to gateway.php.
2. Gateway.php page places cookie.
3. User then picks between 2 options one of witch is the page he was just on.
4. If user picks this option the script does not run because it sees cookie avoiding infinity loop.
5. I only want to use php. Im trying to not use java script or anything.
gateway.php
PHP Code:
<?php
$value = "mobilecookie";
/*setcookie(name,value,expire,path,domain,secure)*/
setcookie("mobilecookie",$value, time()+60*60*24*30);
?>
index.php
PHP Code:
How would I code this?
<?php
if cookie exist go to url(index.php)
if cookie does not exist run script once(script.php)
?>
|