Jump to content

Cookies and PHP


joebez

Recommended Posts

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

 

Link to comment
Share on other sites

<?
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 :)

Link to comment
Share on other sites

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']

;)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.