Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member shoffman3572's Avatar
    Join Date
    Jul 2008
    Location
    Fullerton, CA
    Posts
    137
    Member #
    16990
    I wonder if someone else has come across this problem.. I have a php script that first checks to see if a specific cookie is available. If it isn't, then a code is pulled from a mysql database - then a cookie is created to store that code and the page is reloaded. here's the example code:

    if (!isset($_COOKIE['NEWCOOKIE']))
    {
    // then get a code to store in a cookie
    $code = 'exam-plec-ode1';
    }

    $hoursLeft = date ("H", mktime(23-date("H"))) * 3600;

    setcookie("NEWCOOKIE", $code , time()+$hoursLeft, "/", "", 0);

    header("location: http://www.example.com/samePageWeStartedOn.php"); // reloads the page

    the page reloading part of this doesn't seem to work on my iPad... ? works in all browsers on my desktop - but on my ipad I have to manually refresh the page to set the cookie. This code is at the start of my page before any content is loaded.

    Any ideas?

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    If there is a cookie set, the variable $code never gets a value.
    $code only gets a value if there is NO cookie set.

    That's not really the solution to your problem, but something I noticed.

    I would think it would look like this:

    if (!isset($_COOKIE['NEWCOOKIE']))
    {
    // then get a code to store in a cookie
    $code = 'exam-plec-ode1';
    }
    else{
    // cookie must be set
    $code = $_COOKIE['NEWCOOKIE'];
    }

    Now, when you set the cookie, $code always has a value of some kind.

    Is it possible that your iPad doesn't work if $code is null or undefined?


  4. #3
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    You may need to die(); after your header redirect. Else wrap it in die(...) which might be neater, or even exit; (many ways to do it.. tsk tsk).

    Otherwise there is this function I found on the php.net site that has always worked for me:

    PHP Code:
    <?php

    function Redirect($Str_Location$Bln_Replace 1$Int_HRC NULL)
    {
            if(!
    headers_sent())
            {
                
    header('location: ' urldecode($Str_Location), $Bln_Replace$Int_HRC);
                exit;
            }

        exit(
    '<meta http-equiv="refresh" content="0; url=' urldecode($Str_Location) . '"/>'); # | exit('<script>document.location.href=' . urldecode($Str_Location) . ';</script>');
        
    return;
    }

    ?>
    shoffman3572 likes this.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  5. #4
    Senior Member shoffman3572's Avatar
    Join Date
    Jul 2008
    Location
    Fullerton, CA
    Posts
    137
    Member #
    16990
    @Ganners - I fellow Brit(?) with what looks like a more thorough way to make this work.. I will give this a try. Thanks!

    @mlseim - many thanks for taking the time to respond.



Remove Ads

Posting Permissions

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

Search tags for this page

php ipad header

Click on a term to search for related topics.
All times are GMT -6. The time now is 02:38 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com