cookies and ie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

cookies and ie

Post by m3rajk »

i have an issue with cookies not working properly in m$ie. no clue what or why.
i had a post here on it that got deleted. here's some links to show what i'm talking about:
http://www.findyourdesire.com/forums.php?fid=2&tid=12
this is from a diff forum and SHOULD work still. i get timeout issues with the site now.
http://www.webmaster-forums.net/showthread.php?t=23571

the php code that i use to set cookies:

Code: Select all

[dcfydllc@seed dcfydllc]$ cat includes/fyd.funcs.php | more
<?php
# functions used by multiple FindYourDesire pages

function cookies($action){ # inserts cookies
  include("/home/dcfydllc/includes/fyd.altincs.php"); # includes file
  if($action=='join'){ # log in the person who just joined
    $ims=array(); # empty array for any ims we might find unread
    $db=mysql_connect($host, $login2, $pass2) or die("cannot access mysql"); # get the sql connection
    $fyd=mysql_select_db($dbname, $db) or die("cannot connect to db"); # select the db
    $un=$_POST['un']; $pw=$_POST['pw']; # what we wont change on-the-fly
    $fprefs=mysql_query("SELECT uid, gmt_offset, tds, login_duration, msgs FROM users WHERE username='$un' AND password='$pw
'", $db); # get the prefs
    if(mysql_num_rows($fprefs)>0){ # we can update the cookies
      $prefs=mysql_fetch_array($fprefs); $gmto=$prefs['gmt_offset']; $utds=$tdc[$prefs['tds']]; 
      $duration=$durr[$prefs['login_duration']]; $accepts=($prefs['msgs']*1); $uid=$prefs['uid'];
      $expire=(time()+($duration*60));
      setcookie('un', $un, $expire); # set username
      setcookie('pw', $pw, $expire); # set password
      setcookie('login', 1, $expire); # set login
      setcookie('gmto', $gmto, $expire); # set the gmt offset
      setcookie('utds', $utds, $expire); # set the time display style
      $active=gmdate("Y-m-d H:i:s", time());
      $update=mysql_query("UPDATE users SET last_activity='$active' WHERE username='$un'", $db); # try to update users (we d
on't really care if it fails)
    }
  }elseif($action=='logout'){ # make all cookies expire
    $expire=time()-(60*60*24*7); # set expire to 60 sec*60 min*24 hrs* 7 days ago (make sure a lagging computer will kill it
 even if my host is in new zealand)
    setcookie('un', NULL, $expire); # makes user name expire & sets it to NULL incase their computer errs
    setcookie('pw', NULL, $expire); # makes password expire & sets it to NULL incase their computer errs
    setcookie('login', NULL, $expire); # makes login expire & sets it to NULL incase their computer errs
    setcookie('utds', NULL, $expire); # makes the tds expire & sets it to NULL incase their computer errs
    setcookie('gmto', NULL, $expire); # makes the gmt offset expire & sets it to NULL incase their comp errs
  }elseif($action=='update'){ # updates cookies (keeping you logged in) & returns waiting messages (optional)
    if(isset($_COOKIE['login'])&&($_COOKIE['login'])){ # we're logged in
      $ims=array(); # empty array for any ims we might find unread
      $db=mysql_connect($host, $login2, $pass2) or die("cannot access mysql"); # get the sql connection
      $fyd=mysql_select_db($dbname, $db) or die("cannot connect to db"); # select the db
      $un=$_COOKIE['un']; $pw=$_COOKIE['pw']; # what we wont change on-the-fly
      $fprefs=mysql_query("SELECT uid, gmt_offset, tds, login_duration, msgs FROM users WHERE username='$un' AND password='$
pw'", $db); # get the prefs
      if(mysql_num_rows($fprefs)>0){ # we can update the cookies
        $prefs=mysql_fetch_array($fprefs); $gmto=$prefs['gmt_offset']; $utds=$tdc[$prefs['tds']]; 
        $duration=$durr[$prefs['login_duration']]; $accepts=($prefs['msgs']*1); $uid=$prefs['uid'];
        $expire=(time()+($duration*60));
        setcookie('un', $un, $expire); # set username
        setcookie('pw', $pw, $expire); # set password
        setcookie('login', 1, $expire); # set login
        setcookie('gmto', $gmto, $expire); # set the gmt offset
        setcookie('utds', $utds, $expire); # set the time display style
        $active=gmdate("Y-m-d H:i:s", time());
        $update=mysql_query("UPDATE users SET last_activity='$active' WHERE username='$un'", $db); # try to update users (we
 don't really care if it fails)
        if($accepts){ # person accepts ims
          if($accepts>5){ # the user wants them ALL
            $fims=mysql_query("SELECT msg_id, from_un FROM msgs WHERE to_id='$uid' AND viewed='0'", $db);
            while($gimid=mysql_fetch_array($fims)){ # while there's ims
              $ims[]=$gimid; # record the msg_id
            }
          }else{ # user wants $accepts amount
            $fims=mysql_query("SELECT msg_id, from_un FROM msgs WHERE to_id='$uid' AND viewed='0' ORDER BY msg_id ASC LIMIT 
$accepts", $db);
            while($gimid=mysql_fetch_array($fims)){ # while there's ims
              $ims[]=$gimid; # record the msg_id
            }
          }
        }
      }
    } # end cookie updating
    return $ims;
  }
}
from sql
mysql> select uid, username, gmt_offset,login_duration from users;
+-----+-----------------+------------+----------------+-------+
| uid | username | gmt_offset | login_duration | issue |
+-----+-----------------+------------+----------------+-------+
| 5 | Neo | -5.00 | 4 | No |
| 6 | Peaches11 | -5.00 | 2 | |
| 7 | Teena01 | -5.00 | 4 | Yes |
| 8 | LadyAndrea | -5.00 | 7 | No |
| 9 | hellokitty | -5.00 | 1 | Brwsr |
| 10 | alliwantisU2 | -5.00 | 2 | |
| 11 | pryncessc | -5.00 | 2 | |
| 12 | mickeyisagyrl | -5.00 | 2 | |
| 13 | skool4zeros | -5.00 | 7 | No |
| 14 | JerseyGirl | -5.00 | 2 | No |
| 15 | nuclearchildren | -5.00 | 2 | |
| 16 | hotlilnikkie | -5.00 | 2 | |
| 17 | PrincessStone | -5.00 | 2 | |
| 18 | is0lati0n | 10.00 | 7 | No |
| 19 | Asteca | -5.00 | 2 | Yes |
| 20 | Goldmaskatl | -5.00 | 2 | No |
| 21 | TheNerd | -5.00 | 5 | No |
| 22 | blondee | -5.00 | 2 | No |
| 23 | scraps | -5.00 | 2 | No |
| 24 | PurelyCanadian | -7.00 | 7 | No |
| 25 | ironwarrior | -5.00 | 2 | |
| 26 | Fila | -5.00 | 2 | No |
| 27 | rANDOMs | -5.00 | 2 | |
| 28 | AnonymousBlonde | -5.00 | 2 | |
| 29 | Evanescence | -5.00 | 2 | Yes |
| 30 | sexyjess | -5.00 | 2 | No |
| 31 | kinkycowgirl | -5.00 | 7 | No |
| 32 | squigga23 | -5.00 | 2 | |
| 33 | Koshko | -5.00 | 2 | |
| 34 | carlton_huffman | -5.00 | 2 | |
| 35 | felinedarkness | -5.00 | 2 | No |
| 36 | Rain | -5.00 | 2 | |
| 37 | vixy | -5.00 | 2 | No |
| 38 | angel | -5.00 | 2 | Yes |
| 39 | liciousness | -5.00 | 2 | No |
| 40 | tigerpaws | -5.00 | 2 | |
| 41 | coblondie | -5.00 | 2 | No |
| 42 | cows_n_penguins | -5.00 | 2 | |
| 43 | Nephalim | -5.00 | 2 | |
| 44 | m2spoild | -8.00 | 2 | Brwsr |
| 45 | Darkened_Star | -5.00 | 7 | No |
| 46 | la_izzi | -5.00 | 2 | No |
| 47 | cmang | -5.00 | 2 | No |
| 48 | uzaho | -5.00 | 2 | |
| 49 | sterling | -5.00 | 2 | No |
| 50 | Sunni | -5.00 | 2 | |
| 51 | Verbena | -5.00 | 2 | |
+-----+-----------------+------------+----------------+-------+
47 rows in set (0.00 sec)

mysql>
# w/issues: 4
#w/out issue: 20
# definitely browser dependant: 2
total reporting: 26 of 47

i know that one of the two that's definitley the browser was using aol's browser. switching to mozilla fixed it. also fixed some minor display issues for her.any help in figuring out how to get ti working for M$IE and aol's browser would be greatly appreciated
teniosoft
Forum Newbie
Posts: 15
Joined: Tue Feb 03, 2004 1:01 am
Location: Portland, Or

Post by teniosoft »

I didn't look through your code but, I thought I would just bring up an issue with MSIE 6.0 and cookies because this could be your problem. You can not get a 3rd party cookie from a website in a frame without a privacy policy. Look up 3rd party cookes I think it is p3p for an acronym.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

ok. just did a quick google. lots of stuff on that. however, i'm not entirely sure that it's going to be useful because everything has but one domain: findyourdesire.com

also not everyone with M$IE is having the issue. i have 6.0 and i have my privacy on high and i'm abble to use it. the ones with the issue seem to be on 5.5, and i think their privacy is lower.
Post Reply