The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: [php] Could not set cookie in IE7

  1. #1

    [php] Could not set cookie in IE7

    http://levichi.com/v2/

    I am using PHP to store cookies which will remember the user's language. Users are also allowed to change their language by clicking their country's flag (circled in pink), and the change will be reflected in the cookie. Everything works fine in Firefox, but on IE7 the cookie is stuck on "english". Debugging code is circled in pink on the bottom of the screeenshot.



    BTW, I have two language variables, because the cookie language variable sometimes does not reflect the language the user is changing to. Recall that cookie variables only update when the PHP page is refreshed.

    PHP Code:
    $language1 $_GET['language'];
    $language2 $_COOKIE['language'];

    // first time user - default to english
    if(!$language2)
        
    setcookie('language''english'time() + 25920000);

    // changing to a different language
    else if(($language1 == 'german') || ($language1 == 'english'))
        
    setcookie('language'$language1time() + 25920000); 
    Last edited by NeoDreamer; January 1st, 2008 at 09:02 PM.

  2. #2
    PHP Code:
    $language1 $_GET['language'];
    $language2 $_COOKIE['language'];

    // first time user - default to english
    if(!isset($language2)) {
        
    setcookie('language''english'time() + 25920000);
    }

    // changing to a different language
    elseif(($language1 == 'german') || ($language1 == 'english')) {
        
    setcookie('language'$language1time() + 25920000);


  3. #3
    I'm confused when I should use !isset and when I should use just !.

  4. #4
    ! means not.

    So !isset would mean is not set.

  5. #5
    my php book uses ! quite often
    PHP Code:
    <?php

       $a
    ;
       if(!
    $a)
          echo 
    'a is not set'// this will be displayed

       
    $a $b;
       if(!
    $a)
          echo 
    'a contains nothing'// this will be displayed

  6. #6
    Yeah, it works pretty much everywhere, it's really useful shorthand.

  7. #7
    Since the cookies don't work for IE7, why don't you use sessions?
    Web Design and Web Development blog
    Designer Notice: Browser List for design compatibility

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012