小编ant*_*n2g的帖子

如何使用PHP或JS使用HttpOnly删除cookie

我有一个包含这些参数的cookie:

Name:   workgroup_session_id
Content:    ""
Domain: agrobman1.tsi.lan
Path:   /
Send for:   Any kind of connection
Accessible to script:   No (HttpOnly)
Created:    Wednesday, November 4, 2015 at 9:31:58 AM
Expires:    When the browsing session ends
Run Code Online (Sandbox Code Playgroud)

我试图使用此代码使用PHP删除cookie:

setcookie("workgroup_session_id", "\"\"", time() - 3600, "/", "agrobman1.tsi.lan", false, true);
Run Code Online (Sandbox Code Playgroud)

但我仍然无法删除它.有谁知道如何使用PHP或JS删除此类型的cookie?

javascript php cookies cookie-httponly

11
推荐指数
1
解决办法
1万
查看次数

使用Javascript调用外部API

我需要使用Javascript从我的网页向外部服务器发出POST请求.身体和反应都是json.我无法弄清楚如何进行此调用或使用哪些工具.我该如何打电话?

这是我到目前为止使用jQuery和ajax:

var body = '{"method":"getViews","params":{"filter":{"operator":"and","clauses":[{"operator??":"matches","value":"'+ inputValue +'"}]},"order":[{"field":"name","ascending":true}],"page":{"startIndex":0,"maxIt??ems":5}}}';
var response = $.ajax({
           url: "http://" + environment + "/vizportal/api/web/v1/getViews",
           method: "post",
           dataType:'json',
           data: JSON.stringify(body),
           headers: {
            'Content-Type': 'text/plain',
            'X-XSRF-TOKEN' : XSRFToken,
            'Cookie': 'workgroup_session_id='+workgroupSessionId+';XSRF-TOKEN='+XSRFToken
           },
           success:function(response){
                alert("success");
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
                alert("Status: " + textStatus); alert("Error: " + errorThrown); 
            } 
        });
Run Code Online (Sandbox Code Playgroud)

它发出的警告只是说"状态:"和"错误:"

控制台说这个"XMLHttpRequest无法加载http:// [domain]/vizportal/api/web/v1/getViews.请求的资源上没有'Access-Control-Allow-Origin'标头.来源' http://因此,[domain] '不允许访问.响应的HTTP状态代码为405."

javascript api post

10
推荐指数
1
解决办法
3万
查看次数

清除AWS Redshift上的缓存

我正在对AWS Redshift进行测试,并且为了复制真实世界的场景,我需要不对我的测试查询进行缓存,以免给出错误的性能图.有没有办法让我在查询运行之间清除Redshift缓存?

amazon-web-services amazon-redshift

9
推荐指数
2
解决办法
4519
查看次数

如何在文本框中更改XAML中的字符间距?

如何在文本块中更改WPF应用程序中的字符间距.也称为字符的字距调整或跟踪.

wpf xaml character spacing kerning

8
推荐指数
1
解决办法
1万
查看次数

从API结果在php网页中显示PNG图像

创建此问题是因为我的上一个问题在不重复时被标记为重复。

我有一个 GET API 调用返回 UTF-8 PNG 图像。我正在从 PHP 进行调用,并希望显示嵌入在网页中的 PNG 缩略图。有人可以帮我弄清楚如何将图像与网页的其余部分内嵌显示吗?到目前为止,我只是获取 CURL 响应并将其回显到页面。这是我所看到的。先感谢您。

$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,'$url');
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
curl_setopt($curl,CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
$headers = array( 'X-Tableau-Auth: ' . $GLOBALS['authToken'] );
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$resp = curl_exec($curl);
echo $resp;
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($resp, 0, $header_size);
$body = substr($resp, $header_size);
echo $body;
curl_close($curl);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

php api curl

1
推荐指数
1
解决办法
3066
查看次数