我正在尝试用javascript设置一个cookie,然后用php在其他页面中读取它.我可以通过编写来编写cookie
document.cookie = cookieName+"="+cookieValue;
Run Code Online (Sandbox Code Playgroud)
我部分工作.- 写了cookie,我$_COOKIE[cookieName]只能在同一个网页上阅读.
这真的不是很有用.我需要在另一页中阅读.我通常在asp.net和c#中开发,所以我对php很新.难道我做错了什么?
感谢您的时间!
EDIT1:两个页面都在同一个域中.例如.site.com/index.php - > site.com/index2.php
EDIT2:cookie通过以下方式设置在一页中:
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
Run Code Online (Sandbox Code Playgroud)
而在另一个页面中它无法访问,但在同一页面它可以...
EDIT3:我尝试设置域名并添加path=<?php echo $_SERVER['HTTP_HOST']; ?>到javascript代码...仍然没有..
编辑4:到目前为止我有..
document.cookie = cookieName+"="+escape(cookieValue)+"; expires="+expire.toGMTString()+"; path=/"+"; domain=.<?php echo $_SERVER['HTTP_HOST']; ?>";
Run Code Online (Sandbox Code Playgroud)
而且我仍然可以从同一页面阅读cookie.
EDIT5:哦......我的......上帝...这一直都是一个错字...只需要删除"path =/"+" ; dom ......"我现在对自己感到羞耻...在此期间我也重置了我的饼干,所以Jared现在我不幸地接受你的帖子作为anwser ...我给我的名字带来了耻辱!!! ....
我正在一个网站上工作,目前使用@ font-face tehnique(this + this)来加载字体.我注意到一些特殊字符没有正确加载 - >ŠĐŽČĆšđžčć.也就是说,这些字符存在于字体本身中.所以,我做了一个测试...我用@ font-face字体和cufon字体加载了一个测试页...结果如下 - >

当然,这里是代码 - >
<html>
<head>
<script type="text/javascript" src="cufon-yui.js"></script>
<script type="text/javascript" src="ReprobateCRO_400.font.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<script type="text/javascript">Cufon.set('fontFamily', 'ReprobateCRO').replace('h1');</script>
<style type="text/css">
@font-face {
font-family: 'ReprobateCROLASTRegular';
src: url('reprob_cro_last_last-webfont.eot');
src: local('ReprobateCROLASTRegular'),
url('reprob_cro_last_last-webfont.eot?#iefix') format('embedded-opentype'),
url('reprob_cro_last_last-webfont.woff') format('woff'),
url('reprob_cro_last_last-webfont.ttf') format('truetype'),
url('reprob_cro_last_last-webfont.svg#ReprobateCROLASTRegular') format('svg');
font-weight: normal;
font-style: normal;
}
h2{
font-family:ReprobateCROLASTRegular;
}
</style>
</head>
<body>
<h1>--> CUFON --> š?ž?? Š?Ž??</h1>
<br/><br/>
<h2>--> @FONT-FACE --> š?ž?? Š?Ž??</h2>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已尝试从utf8,widnwos1250切换编码,似乎没有任何东西可以与@ font-face tehnique一起使用...
所以,我有两个问题......有谁知道这里发生了什么?并且,如果我切换到使用cufon insted @ font-face …
我有一堆文本,在那个文本中我想替换每个"EXAMPLE"字,它不包含前面的字符a-z或A-Z字符..所以类似" [^a-z]EXAMPLE"..但是当删除时我只想删除"示例",不是它前面的misc字符或它背后的任何字符......
所以在"BLABLAEXAMPLBLA EXAMPLEBLA"中我要输出"BLABLAEXAMPLBLA BLA"
我希望这是明确的:)
感谢您的时间!
我有一个VBA宏脚本,可以删除一些数据.它使用MSIE来刮擦它.我相信MSIE是内存泄漏的核心问题.
我正在初始化变量
Set IE = CreateObject("InternetExplorer.Application")
Run Code Online (Sandbox Code Playgroud)
我做了一点测试,看看内存是如何使用的.
我创建了一个循环,它只生成1个IE实例并ping同一个网站.记忆似乎没有韭菜.
然后我做了一个循环,总是ping不同的站点,内存使用开始随着每个请求而增加.
我还做了一个测试(我在下面发布),在每次迭代中创建NEW对象并在最后删除它.删除部分似乎不起作用.
似乎IE的实例正在缓存请求,因此对象变得越来越大.这只是一个假设.
这是我用来测试泄漏的示例代码.
Do While True
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter
IE.Visible = True
Do While IE.readyState <> 4 Or IE.Busy = True
Application.Wait Now() + TimeValue("00:00:01")
DoEvents
Loop
Application.Wait Now() + TimeValue("00:00:01")
Counter = Counter + 1
Range("A" & Counter).Value = "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter
IE.Quit
Set IE = Nothing
Loop
Run Code Online (Sandbox Code Playgroud)
任何输入都会很棒!
我正在尝试使用MSDOS"attrib"命令使用C#隐藏文件夹.
现在,我可以通过在批处理文件中编写"attrib"命令+参数,运行该文件Process.Start(),然后删除它来实现这一点.我想知道,我可以直接从C#那样做吗?
这是我到目前为止所尝试的...(下面的代码不起作用)
public static void hideFolder(bool hide, string path)
{
string hideOrShow = (hide) ? "+" : "-";
Process.Start("attrib " + hideOrShow + "h " + hideOrShow + "s \"" + path + "\" /S /D");
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都会得到满足!感谢名单!