tags:

views:

177

answers:

1

Hi,

I have a PHP text-size select function within a Drupal site:

It uses this selector...:

<ul id="font-sizes">
        <li class="one"><a href="<?php global $base_url; print $base_url;?>/sites/all/themes/x/resize.php?set=small">Normal Font-Size</a></li>
        <li class="two"><a href="<?php global $base_url; print $base_url;?>/sites/all/themes/x/resize.php?set=medium">Medium Font-Size</a></li>
        <li class="three"><a href="<?php global $base_url; print $base_url;?>/sites/all/themes/x/resize.php?set=large">Large Font-Size</a></li>
</ul>

...which modifies a stylesheet link...:

<link rel="stylesheet" type="text/css" media="screen"  href="<?php global $base_url; print $base_url;?>/sites/all/themes/x/<?php echo isset($_COOKIE['sitestyle'])?$_COOKIE['sitestyle']:'small'; ?>.css" />

... by using this file (resize.php):

<?php setcookie ('sitestyle', $_GET['set'], time()+31536000,'/', 'mysite.co.uk', '0'); header("Location: ".$_SERVER['HTTP_REFERER']); ?>

Now, my problem is that it works fine when logged into the CMS (as the main admin or a lower level role), but it just does not work when accessing the site as an anonymous user. I've been through the permissions settings, but I can't for the life of me see anything that would affect this. I'm guessing therefore it's do to with some higher-level PHP access thing that is beyond me.

Any ideas?

+2  A: 

Drupal is often set to cache pages for anonymous users. So even if the cookie is set the page returned will be the same.

If your server can handle the load you could disable caching in the admin performance page and it should then work.

Jeremy French
Yep, that's got it! Many thanks.
james6848