Jump to content

cookies for choosing site structure


story97

Recommended Posts

Hello,

I'm a designer, not a coder, but I'm in need of a little help.

The site i'm working on now has a flash header and menu. This can be a problem for people with Active-X turned off. So I want to offer an option.

Load the site using the flash. Right under the menu, have a link "Non flash site". Now, by itself this might be simple. but again, i'm not a programmer. I'd like this setting stored in a persistent cookie so the user only has to see things they don't want to once.

Is this too broad of a question?
Link to comment
Share on other sites

No, it's not broad question...

On your page, check if the cookie is present, if it is set, then show output based on the cookie value. If it's not set, add your link [b]Non flash site[/b] that point back to that page and set the cookie, and then show the page where non flash content is shown!

example... (change .domain.com) to (.your_domain.com)

[code]<?php

// page

// show flash, default

$type = 1;

/* first check if we have display change request */

if ( isset ( $_GET['display'] ) )
{
$test = intval ( $_GET['display'] );

if ( $test == 0 || $test == 1 )
{
// valid change request

$type = $test;
}

setcookie ( 'non_flash', $type, ( time () + 60*60*24*365 ), '/', '.domain.com' );
}

/* else if cookie is set */

else if ( isset ( $_COOKIE['non_flash'] ) )
{
$test = intval ( $_COOKIE['non_flash'] );

if ( $test == 0 || $test == 1 )
{
// valid cookie value

$type = $test;
}
else
{
// cookie set, but not a valid cookie value, so reset the default

setcookie ( 'non_flash', $type, ( time () + 60*60*24*365 ), '/', '.domain.com' );
}
}
else
{
// no cookie set, so set it!

setcookie ( 'non_flash', $type, ( time () + 60*60*24*365 ), '/', '.domain.com' );
}

// now show your page based on $type

if ( $type == 1 )
{
// flash content

echo "<div align='center'>This is a flash filled page<br /><br />Show <a href='/index.php?display=0'>non flash</a> page always!</div>";
}
else
{
// non flash content
echo "<div align='center'>This is a page with no flash<br /><br />Show <a href='/index.php?display=1'>flash</a> page always!</div>";
}

?>[/code]


me!
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.