joebez Posted January 4, 2008 Share Posted January 4, 2008 Hello everybody! I a, trying to come up with a solution and I wonder if one of you have an idear! Lets say that I have 3 sub domains: http://california.mewebsitezx.biz http://nevada.mewebsitezx.biz http://texas.mewebsitezx.biz and I have a splash page on mewebsitezx.biz When a visitor goes to mewebsitezx.biz they will be able to click on a link from the list below: <a href="http://california.mewebsitezx.biz">CA</a> <a href="http://nevada.mewebsitezx.biz">NV</a> <a href="http://texas.mewebsitezx.biz">TX</a> I was wondering if a cookie session should be created to automatically redirect the visitors to the location they have selected in the past? I am not sure how to proceed with this I am sure one of you worked with something similar. Thank you in advance for all the help and creativity. Joe Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/ Share on other sites More sharing options...
JJohnsenDK Posted January 4, 2008 Share Posted January 4, 2008 i think you should go with the cookie session idea, that is what i would have done. if you dont know anything about cookies have a look at the setcookie() function: http://dk.php.net/manual/da/function.setcookie.php Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430455 Share on other sites More sharing options...
drummer101 Posted January 4, 2008 Share Posted January 4, 2008 <? if(isset($_COOKIE['location'])){ echo "<meta http-equiv=\"refresh\" content=\"5; url=http://" . $_COOKIE['location'] . "/mewebsitezx.biz\">"; echo "Please wait 10 seconds while the page loads, or click <a href=\"http://" . $_COOKIE . "/mewebsitezx.biz\">here</a> to be redirected."; } else { echo "Please select a location:<br><a href=\"http://california.mewebsitezx.biz\">CA</a><br><a href=\"http://nevada.mewebsitezx.biz\">NV</a><br><a href=\"http://texas.mewebsitezx.biz\">TX</a>"; } ?> Then on each respective page, check if the cookie exists, if not, prompt the user if they'd like to accept it and be remembered next time they visit, then set the cookie, else, do nothing. Hope that gets you started Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430465 Share on other sites More sharing options...
joebez Posted January 4, 2008 Author Share Posted January 4, 2008 Every thing works fine but the http refer it is not referring, I wonder if cookies are getting set! :'( Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430689 Share on other sites More sharing options...
drummer101 Posted January 4, 2008 Share Posted January 4, 2008 <?php if(isset($_COOKIE['_____'])){ echo "cookie is set<br>Value is: " . $_COOKIE['_____']; } else { echo "Something went wrong, and the cookie wasn't set"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430695 Share on other sites More sharing options...
joebez Posted January 4, 2008 Author Share Posted January 4, 2008 Yep its not setting! Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430703 Share on other sites More sharing options...
revraz Posted January 4, 2008 Share Posted January 4, 2008 I don't see any code in this thread that shows where you set it. Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430718 Share on other sites More sharing options...
drummer101 Posted January 4, 2008 Share Posted January 4, 2008 revraz is right, I never gave you the code to set the cookie. JJohnsonDK gave you a link which you need to read to understand how the cookies work. Also, reference my above post Then on each respective page' date=' check if the cookie exists, if not, prompt the user if they'd like to accept it and be remembered next time they visit, then set the cookie, else, do nothing.[/quote'] Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-430729 Share on other sites More sharing options...
joebez Posted January 5, 2008 Author Share Posted January 5, 2008 Uhh all these problems because I had a special bytes before the <?php !!!! make sure you have no special bytes before "<?") <? header("Content-Type: text/html; charset=utf-8"); if(isset($_COOKIE['location'])){ Thank you drummer101 it works great Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-431025 Share on other sites More sharing options...
drummer101 Posted January 5, 2008 Share Posted January 5, 2008 no problem Quote Link to comment https://forums.phpfreaks.com/topic/84483-cookies-and-php/#findComment-431320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.