Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

IE won't save cookies from PHP...?

Options
  • 11-07-2007 5:32pm
    #1
    Registered Users Posts: 68,317 ✭✭✭✭


    OK, really weird and irritating one this.

    I wrote an extremely simple script a while back for a client to allow them to upload images and text to their own site.

    Authentication is a simple login box which checks against a hardcoded username and password, and then sets a 15 minute cookie on the machine. The cookies get checked at every page to ensure that they're still logged in. It was working for months until spontaneously I was told that the login was no longer working. They could log in once, but then no matter what they clicked on, they go logged out.

    Easy one I thought, corrupt cookies or cached pages or something. It was working fine on multiple machines for me. So I had refresh her cache, delete temp files, and a whole pile of toing-and-froing took place. I assumed she just wasn't doing something right.

    Then I tried IE, and lo and behold, I was experiencing the same problem. Firefox worked, no problems, IE didn't. IE wasn't even setting the cookies (even though it told PHP that the cookies were going through fine).

    I'm totally lost. The cookies are set as normal:
    setcookie("uname", $username, (time()+(15*60));
    setcookie("pwd", $password, (time()+(15*60));
    
    In my head, I've pretty much narrowed it down to two things:

    1. Server config
    2. Browser config/patches

    The scripts work fine on my local machine, and on my intranet. Just not on the website. These would also apply different security settings for each zone, with the website in the Internet zone having the strictest settings. But that shouldn't affect cookies. Since the problem spontaneously occured, that's what leaning me towards server config.


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    I got it sorted, even if I am still perplexed.

    It's definitely a problem with IE and security settings, I just can't figure out what.

    I replaced the contents of the authentication function so that it's using sessions instead, and it works fine now.

    Odd.


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    That is a puzzler though to be honest I would have used sessions instead of cookies from the start (even though the idea is similar - just the way I've always coded server side code). May I ask what version of IE was causing the problem?


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    IE6 Sp2 & IE7 were both experiencing the same issue. I didn't test any other versions.

    I would indeed have used sessions, except at the time I wrote it I didn't know anything about them :D


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Just a silly question but have you tried setting cookies on the site by other means? i.e. a client side javascript maybe. I'm just curious to know why IE would refuse cookies out of hand but allow sessions (which basically are cookies too) in other words is it a PHP issue or a IE issue.

    When I started coding I used to use cookies too but only client side never server side. They used to do my melt in as the only tutorials on them I could find at the time were very vague and not so helpful. I finally got a function to work in IE and then it wouldn't work in NS (this was back in the day :) Man I feel old :) ) and vice versa. I nearly wept when I found out about sessions!

    At this stage though anything cody like that should work in all browsers, it's only really CSS that causes issues with the browsers these days (I am of course over simplifying I'm sure there are millions of things one does that the others don't)

    -RD


Advertisement