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!