Jump to content

Archived

This topic is now archived and is closed to further replies.

story97

cookies for choosing site structure

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?

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
Wow fantastic.

I'm remote right now But I'll give this a shot in a  couple hours. I REALLY appreciate it.

Share this post


Link to post
Share on other sites
Nevermind I copied and pasted the code to my PDA then to the site.

This is exactly what I wanted. Thank you so much!

Share this post


Link to post
Share on other sites

×

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.