...

View Full Version : "Remember my prefrence" cookie.



Crazydog
06-18-2005, 02:00 AM
Right now on my website I have a splash page for certain browsers.
For example, if you visit it on IE, you will get a message with a link to enter the site, while Firefox goes directly to the site.

I am wondering how to create a cookie that I can set to something along the lines of:

"If a checkbox is checked, the browser will skip the splash page for recurring visits"

How would I create this? Is it even a cookie? Should I make it in Javascript?

Thanks.

SeeIT Solutions
06-18-2005, 03:59 AM
Try this


<?php
//put this at the top of index.php (or whatever the splash screen is called)

if (isset($_COOKIE['splash'])) {
header("Location: home.php"); //home.php = the site
}

?>


<?php
//put this at the top of home.php (or whatever the name of the first page is)

if (isset($_POST['checkbox'])) {
setcookie('splash','true',time()+99999999999);
}

?>

Crazydog
06-18-2005, 07:42 PM
well I have it go to "index.php" which then either fowards to .../home/(index.php) or /error/(index.html)

But how would I make the choice to show the splash page or not?

Like I said, a check box that says "remember my prefrence"

do I not put it on the page with the browsercheck javascript?

SeeIT Solutions
06-19-2005, 03:52 AM
Use this for the splash screen. It's very simplified but you should be able to work it out. If not post a link to your site.


<?php

if (isset($_COOKIE['splash'])) {
header("Location: home/index.php");
}

//all header information goes here (eg, <html><head> etc)

?>
<form name="form" action="home/index.php" method="post">
<a href onClick="document.form.submit()"><img src="images/splash.jpg"></a><br><input type="checkbox" name="remember" value="1"></form>


and use this for the home/index.php


<?php

if (isset($_POST['remember']) && $_POST['remember'] == "1") {
setcookie('splash','1',time()+99999999999);
} elseif (isset($_POST['remember']) && $_POST['remember'] != "1") {
header("Location: ../error");
}

//rest of the page

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum