如何使用js来获取cookie的值

如何使用js来获取cookie的值,第1张

<!DOCTYPE HTML>

<html lang="en-US">

<head>

<meta charset="UTF-8">

<meta name="keywords" content="白菜编辑部">

<title>白菜编辑部</title>

<style type="text/css">

</style>

<script type="text/javascript">

function readCookie (name)

    {

    var cookieValue = "";

    var search = name + "=";

    if (documentcookielength > 0)

    {

    offset = documentcookieindexOf (search);

    if (offset != -1)

    {

    offset += searchlength;

    end = documentcookieindexOf (";", offset);

    if (end == -1)

    end = documentcookielength;

    cookieValue = unescape (documentcookiesubstring (offset, end))

    }

    }

    return cookieValue;

    }

    function writeCookie (name, value, hours)

    {

    var expire = "";

    if (hours != null)

    {

    expire = new Date ((new Date ())getTime () + hours  3600000);

    expire = "; expires=" + expiretoGMTString ();

    }

    documentcookie = name + "=" + escape (value) + expire;

    }

    

    writeCookie ("myCookie", "my name", 24);

    alert (readCookie ("myCookie"));

</script>

</head>

<body>

</body>

</html>

WSockExpert是抓包工具,VB要实现的话比较麻烦

如果你只想获取COOKIE值的话,可以用WebBrowser控件

Private Sub Form_Load()

WebBrowser1Navigate ">

setcookie

的第三个参数,超时时间,设置上去就可以了

如果不同页面读取,还有$path,$domain等有关,请设置正确的值

手册中的demo

<php

$value

=

'something

from

somewhere';

setcookie("TestCookie",

$value);

setcookie("TestCookie",

$value,

time()+3600);

/

expire

in

1

hour

/

setcookie("TestCookie",

$value,

time()+3600,

"/~rasmus/",

"examplecom",

1);

>

int id = 1;

>

两种方式:

一、

接口,可以pip install requests模块,安装一个requests,对接口支持简单好用

例子,写一个getcookie()方法

import requests

def getcookie():

data={'username':username,'password':pwd}

session=requestssession()

loginurl=">

以上就是关于如何使用js来获取cookie的值全部的内容,包括:如何使用js来获取cookie的值、如何用VB获取COOKIE值、PHP如何获取客户端(用户PC) COOKIE内的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/9794517.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-02
下一篇 2023-05-02

发表评论

登录后才能评论

评论列表(0条)

保存