跨域共享cookie
来源:互联网 发布:软件三库是啥意思 编辑:程序博客网 时间:2024/06/05 06:55
跨域共享cookie的原理是通过一个图片加载php文件的方法
1.
var expires_date = new Date( today.getTime() + (expires) );domain_arr = ['mfancy.com','www.mfancy.it','www.mfancy.de','www.mfancy.es','www.mfancy.fr'];this_expires = expires/1000;//document.write("thisdomain:"+domain+"<br/>");for( xx in domain_arr){this_domain = domain_arr[xx];//document.write("otherdomain:"+this_domain+"<br/>");if(this_domain != domain){this_url = "http://"+this_domain +"/" +"setcookie.php" + "?name="+name+"&value="+value+"&expires="+this_expires+"&path="+path+"&domain="+this_domain+"&secure="+secure;var thisimg = new Image(1, 1);thisimg.src = this_url;}}
在使用js设置cookie的时候,需要把这个值同步到其他域名,可以使用把这个值获取过来,然后通过图片加载php文件的方式
把这个值传递到其他网站的cookie中,然后,其他网站都可以获取到这个值,然后设置cookie,php的文件如下,这样就实现了各个网站共享cookie了。
2cookie.php<?phpif(isset($_GET['name']) && isset($_GET['value']) ){$name = $_GET['name'];$value =$_GET['value'];$expire = $_GET['expire'] ? $_GET['expire'] : 3600 * 24 ;$expire = time()+ $expire;$path = $_GET['path'] ? $_GET['path'] : "/";$domain = $_GET['domain'] ? $_GET['domain'] : "";$secure = $_GET['secure'] ? $_GET['secure'] : "";setcookie($name,$value,$expire,$path,$domain,$secure);echo "success";exit;}echo "fail";?>
上面的代码的意思是,几个网站
0 0
- 跨域共享Cookie
- cookie跨域共享
- Cookie跨域共享
- 跨域共享cookie
- 跨域共享cookie
- 实现跨域cookie共享
- 实现跨域cookie共享
- 解决跨域cookie共享
- 实现跨域cookie共享
- 实现跨域cookie共享
- COOKIE 的跨域共享
- [跨域] -- cookie跨域共享
- Cookie的跨域共享
- cookie用法小结 cookie.setPath 跨域共享
- 实现跨域cookie共享(转载)
- jquery.cookie中的操作(跨域共享)
- 实现跨域cookie共享(转载)
- 实现跨域cookie共享(转载)
- 优秀的编程风格(Java篇)
- 【Android工具类】用户输入非法内容时的震动与动画提示——EditTextShakeHelper工具类介绍
- ecshop实现立刻购买与添加到购物车并存的方法(转)
- 视频稳像 video stabilization
- 配置多个tomcat服务,并用nginx做负载均衡
- 跨域共享cookie
- flash 上传类 带自动压缩功能
- [easyUI] easyUI 在当前Tab新建另一个Tab的方法
- [其它]闹钟基本实现
- [LeetCode]Balanced Binary Tree
- DataStream
- 【Android工具类】Activity管理工具类AppManager
- JSP中常见TOMCAT错误代码原因
- [每日练习]最大公约数问题