域名使用AJAX帖子通过域名B然后域名B设置cookie自我登录 [英] Domain a use AJAX post though domain B then domain B set cookie self to login
本文介绍了域名使用AJAX帖子通过域名B然后域名B设置cookie自我登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
域A的脚本fontend / views codeigniter:
Script at domain A fontend/views codeigniter:
<script>
$(document).ready(function($) {
$.ajax({
type: "POST",
url: "http://domainB/setcookie.php",
data:{
'id': 'value'
},
success: function(data){
console.log(data);
}
});
});
</script>
和http://domainB/setcookie.php文件:
And http://domainB/setcookie.php file:
<?php
setcookie("u_id", $_POST["id"], 0, '/');
?>
并运行http://domainB/index.php文件:
And run http://domainB/index.php file:
The result of $_COOKIE["u_id"] is NULL EMPTY. I want $_COOKIE["u_id"] is "value".
我尝试了什么:
尝试域名活跃域名B setcookie self
What I have tried:
try domain A active domain B setcookie self
推荐答案
(document).ready(function(
(document).ready(function(
){
.ajax({
type:POST,
url:http:// domainB / setcookie .php,
数据:{
'id':'value'
},
成功:函数(数据){
console.log(data);
}
});
});
< / script>
.ajax({ type: "POST", url: "http://domainB/setcookie.php", data:{ 'id': 'value' }, success: function(data){ console.log(data); } }); }); </script>
和http://domainB/setcookie.php文件:
And http://domainB/setcookie.php file:
<?php
setcookie("u_id",
这篇关于域名使用AJAX帖子通过域名B然后域名B设置cookie自我登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文