通过ajax请求更新cookie的值 [英] update the value of a cookie via an ajax request

查看:343
本文介绍了通过ajax请求更新cookie的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为我的localhost应用程序更新cookie的值...



我正在尝试通过ajax请求更新,但它创建了两个cookie。 。

这是我使用的PHP代码..

  $ sessionManifestName  =   manifest _ .md5(time())。  。xml; 

if(isset($ _COOKIE [ TMP_MANIFEST])){
setcookie( TMP_MANIFEST ,time() - 3600, /);
}

的setcookie(<跨度类= 代码串> <跨度类= 代码串 > TMP_MANIFEST,$ sessionManifestName, time()+ 3600, /);





但它在不同的目录中创建两个具有不同值的cookie。



来自根...我有一个cookie,但它们是两个包含这个脚本的目录。



那是..

in ./我有一个./myapp/controller中的TMP_MANIFEST但是

- 我有两个具有不同值的TMP_MANIFEST cookie。



我该如何解决这个问题?

解决方案
sessionManifestName = <跨度类= 代码串> <跨度类= 代码串 >清单_ .md5(time())。 。xml;

if(isset(


_COOKIE [ TMP_MANIFEST ])){
的setcookie(<跨度类= 代码串 > <跨度类= 代码串> TMP_MANIFEST,<跨度class =code-string>
,time() - 3600, /);
}

setcookie( TMP_MANIFEST

sessionManifestName,time()+ 3600, /);





但是它会在不同的目录中创建两个具有不同值的cookie。


来自root的
...我有一个cookie,但它们是包含这个脚本的目录中的两个。



即...

in ./我有一个TMP_MANIFEST但是

in ./myapp/controller-我有两个不同值的TMP_MANIFEST cookie。



我该如何解决这个问题?


How can i update the value of a cookie for my localhost application ...

I am trying to update via an ajax request but its creating two cookies..
this is the php code iam using..

$sessionManifestName = "manifest_".md5( time() ).".xml";		
		
if( isset ( $_COOKIE["TMP_MANIFEST"] ) ){
	setcookie( "TMP_MANIFEST", "", time()-3600, "/"  ) ;
}

setcookie( "TMP_MANIFEST", $sessionManifestName, time()+3600 , "/"  ) ;



But it creates two cookies with the same in different directories with different values..

from the root... i have one cookie but they are two in the dir which contains this script.

that is..
in ./ i have one TMP_MANIFEST but
in ./myapp/controller - i have two TMP_MANIFEST cookies with different values.

How can i fix this?

解决方案

sessionManifestName = "manifest_".md5( time() ).".xml"; if( isset (


_COOKIE["TMP_MANIFEST"] ) ){ setcookie( "TMP_MANIFEST", "", time()-3600, "/" ) ; } setcookie( "TMP_MANIFEST",


sessionManifestName, time()+3600 , "/" ) ;



But it creates two cookies with the same in different directories with different values..

from the root... i have one cookie but they are two in the dir which contains this script.

that is..
in ./ i have one TMP_MANIFEST but
in ./myapp/controller - i have two TMP_MANIFEST cookies with different values.

How can i fix this?


这篇关于通过ajax请求更新cookie的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆