Forum Moderators: open

Message Too Old, No Replies

More Safari Cookie Foolishness

         

JAB Creations

1:03 am on Jun 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Testing Safari 2 on OSX 10.4 with a local build of the next version of my site I've divided my live site's bandwidth cookie in to two separate cookies: audio and bandwidth. However when the person clicks a welcome anchor to set their preference (a get command with?audio=0/1/2&connection=0/1 options) the serverside initially sets the audio cookie and then the bandwidth/connection cookie. However I'm not seeing the bandwidth/connection cookie being set in Safari's preferences (but I see the audio cookie being set). The server's PHP headers create the cookies. Now the thing that strikes me odd is that after I deleted the audio cookie and set the connection cookie Safari created a whole slew of cookies when I updated the site options. So it's not a cookies-per-page limit I'm hitting...unless it's specifically on first load...but I've constantly clicked the same anchor to set the same preferences. Safari is a massive pain with cookies and I'm hoping someone else could shed some light on Safari's incompetency. It works fine on Safari 3/XP btw.

- John

encyclo

7:37 pm on Jun 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe that some of Safari's cookie settings can create problems. Are you certain that "Accept all cookies" is selected in the browser options? Heve you uses the "reset Safari" option to clear out any existing cookies?

JAB Creations

8:40 pm on Jun 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have narrowed it down to yet another browser bug, Safari 2 does not understand encoded URLs.

An example of what I'm using on the version of my site I'm currently working on...

<a href="<?php echo $_SERVER['PHP_SELF'];?>?audio=0&#38;connection=0">Audio Disabled</a>

That choice is for dial-up with audio disabled. I initially tried reading the connection before the audio at the server and that did not help.

What tipped me was when I swapped audio and connection, so it looked like this...

<a href="<?php echo $_SERVER['PHP_SELF'];?>?connection=0&#38;audio=0">Audio Disabled</a>

However now the server wasn't setting the audio cookie! But that was fine because I didn't need any more hints to see this bug. Webkit does not properly process encoded ampersands!

Also using &amp; or & alone does not work (in case those who find this are dealing with the same issue).

The "Fix"
I tried using &amp; and that did not work either. I knew that I'd have to cloak for Safari...again! Thankfully Safari 3 on XP does not suffer from this bug...can anyone confirm on this bug has disappeared from Safari 3 on OSX please?

Here is my cloaking fix. Keep in mind I still have to modify this to detect OSX's presence and not cloak for Windows...

- John

<?php if (!preg_match("/WebKit/", $useragent)) {
// Is not Webkit?>
<div id="broadband">
<span class="highlight">Broadband</span>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?audio=2&#38;connection=1">Hi-Fi Audio Enabled</a>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?audio=0&#38;connection=1">Audio Disabled</a>
</div>

<div id="dialup">
<span class="highlight">Dial-Up</span>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?audio=1&#38;connection=0">Low-Fi Audio Enabled</a>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?audio=0&#38;connection=0">Audio Disabled</a>
</div>

<?php } else {
// Is Webkit
?>

<div id="broadband">
<span class="highlight">Broadband</span>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?webkit=4">Hi-Fi Audio Enabled</a>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?webkit=3">Audio Disabled</a>
</div>

<div id="dialup">
<span class="highlight">Dial-Up</span>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?webkit=2">Low-Fi Audio Enabled</a>
<br />
<a href="<?php echo $_SERVER['PHP_SELF'];?>?webkit=3">Audio Disabled</a>
</div>