0

Hello,

I have a project hosted on a live server has a domain like: www.abc.com

On live domain:
I am unable to set cookies in IE (7, 8, 9, 10) - as it is explained in the code below - (cookies are enabled on the IE browser), but able to set cookies in Firefox, Chrome, Opera and Safari without any problem. The server time is correct (current time of Jordan)

On localhost:
Cookies are working perfect on all browsers!

My code explained exactly as below:

In the page: "localhost/test.php", I put the below code to read the content of show.php which resides in the live server:

 <?php foreach (file('http://abc.com/api/show.php') as $o) echo $o ?>

In the page http://abc.com/api/show.php:

 function hookscript(url){
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.src = url || null;
        document.getElementsByTagName("head")[0].appendChild(s);
    }


    hookscript('http://abc.com/aj/ajax.php?part=1');

In the page http://abc.com/aj/ajax.php:

 function hookscript(url){
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.src = url || null;
        document.getElementsByTagName("head")[0].appendChild(s);
    }

    <?php
    $part = $_GET['part'];
    ?>

    <?php
    if($part==1){
    ?>

        <?php setcookie('test',time(),time()+3600) ?>
        hookscript('http://abc.com/aj/ajax.php?part=2');

    <?php
    }

    if($part==2){
        if(isset($_COOKIE['test'])){
    ?>
            alert('Cookies SET');
        <?php
        }
        else{
        ?>
            alert('Cookies NOT SET'); // WHY!

    <?php
        }
    }
    ?>

Would appreciate your hints! Thank you!

Edited by Moderns

2
Contributors
4
Replies
19
Views
3 Years
Discussion Span
Last Post by LastMitch
0

I am unable to set cookies in IE (7, 8, 9, 10) - as it is explained in the code below - (cookies are enabled on the IE browser), but able to set cookies in Firefox, Chrome, Opera and Safari without any problem. The server time is correct (current time of Jordan)

@Moderns

This is nothing to do with PHP.

PHP can enable cookies on all browsers but in your situation it's more related to a browsers setting rather than code itself.

Check the cookie settings of the other browsers and if they're set to block all or empty on exit make sure all of them have the same setting.

There is a work around with IE version in regards with jQuery/javascript.

I don't think I seen or heard anyone has issue enabling cookies in php, in general.

This is an client-side issue rather a server-side issue.

Does that make sense?

Edited by LastMitch

0

Thanks LastMitch! Actually when I test the code on localhost instead of abc.com, it works fine in IE and all browsers. But, when I test it on abc.com, then it doesn't work in IE but works perfect on (FF, Chrome, Opera and Safari).

It is the first time to face such problem :( I don't find any setting to change in IE, everything seems fine. Could you recommend anything from your side please?

You can try the code on your server and see that. I also tried it on another server but same problem :(

Your help is greatly appreciated :)

Thank you and regards!

0

I am still unable to find an answer! Your help is greatly appreciated! Thank you!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.