在javascript中设置cookie值并用php显示 [英] set cookie value in javascript and displaying it with php
本文介绍了在javascript中设置cookie值并用php显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个输出问题,我似乎无法追查问题,下面是代码:
sample.js
var m_names = new Array(January,February,March,April,May,June,July ,八月,九月,十月,十一月,十二月);
var cmonth = myDate.getMonth();
var cdate = myDate.getDate();
var temp1 = m_names [cmonth];
var tempo = escape(temp1 ++ cdate);
document.cookie = fcookie=+节奏;
output.php
<?php echo implode($ _ COOKIE)?> b
p>
但我想显示存储在速度变量中的日期,
我试着直接显示节奏变化,显示正确的输出,
有什么建议?我想我需要在PHP端添加代码。
解决方案我只是改变了以下内容:
document.cookie ='fcookie ='+节奏;
和
if(isset($ _ COOKIE [fcookie]))
echo $ _COOKIE [fcookie];
else
回声未设定Cookie;
i am having an output problem and i can't seem to trace the problem, here is the code:
sample.js
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var cmonth = myDate.getMonth();
var cdate = myDate.getDate();
var temp1 = m_names[cmonth];
var tempo = escape(temp1 + " " + cdate);
document.cookie=fcookie"=" + tempo;
output.php
<?php echo implode($_COOKIE)?>
and it displays
713qnihjmdt7mdq8eejvlcd1q1
but i want to display the date stored in the tempo variable,
i tried dispaying the tempo variabe directly and it dispalyed the right output,
any suggestions? i think i need to add a code in the php side.
解决方案 i just changed the following
document.cookie='fcookie='+tempo;
and
if (isset($_COOKIE["fcookie"]))
echo $_COOKIE["fcookie"];
else
echo "Cookie Not Set";
这篇关于在javascript中设置cookie值并用php显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文