获取cookie

NSHTTPCookieStorage *sharedHTTPCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

NSArray *cookies = [sharedHTTPCookieStorage cookiesForURL:[NSURL URLWithString:@"file:///Users/jason/Library/Developer/CoreSimulator/Devices/FDFE739C-A564-4F15-8609-C527B436D6E5/data/Containers/Data/Application/7348B5F3-F859-4F16-9DAB-D5B6D3ECEDF9/Documents/html/center.html"]];

NSEnumerator *enumerator = [cookies objectEnumerator];

NSHTTPCookie *cookie;

while (cookie = [enumerator nextObject]) {

NSLog(@"COOKIE{name: %@, value: %@}", [cookie name], [cookie value]);

}

时间: 2024-10-23 20:21:53

获取cookie的相关文章

用WebCollector 2.x爬取新浪微博(无需手动获取cookie)

用WebCollector 2.x 配合另一个项目WeiboHelper,就可以直接爬取新浪微博的数据(无需手动获取cookie) 1.导入WebCollector 2.x和WeiboHelper的所有jar包 两个项目的地址:http://git.oschina.net/webcollector/WebCollector http://git.oschina.net/webcollector/WeiboHelper 2.示例代码: package cn.edu.hfut.dmic.webcol

【学习笔记】JavaScript设置与获取Cookie

获取Cookie: 1 function getCookie(cookiename) { 2 var result; 3 var mycookie = document.cookie; 4 var start2 = mycookie.indexOf(cookiename + "="); 5 if (start2 > -1) { 6 start = mycookie.indexOf("=", start2) + 1; 7 var end = mycookie.i

设置cookie、获取cookie、删除cookie函数封装

//设置cookie函数function setCookie(key,value,t){   var oDate = new Date();   oDate.setDate( oDate.getDate() + t );   document.cookie = key + '=' + encodeURI(value) + ';expires=' + oDate.toGMTString();} //获取cookie函数function getCookie(key){ //通过分号空格拆分开所有co

如何使用js来获取cookie的值

如何使用js来获取cookie的值 读取属于当前文档的所有cookies var allcookies = document.cookie; 定义一个函数,用来读取特定的cookie值. function getCookie(cookie_name) { var allcookies = document.cookie; var cookie_pos = allcookies.indexOf(cookie_name);   //索引的长度 // 如果找到了索引,就代表cookie存在, // 反

js获取cookie值

js获取cookie值,代码如下: 1 function getCookie(key) { 2 var arr = document.cookie.split(';'); 3 var obj = new Object(); 4 for(var i = 0; i < arr.length; i++) { 5 var tmp = arr[i].split('='); 6 obj[tmp[0]] = tmp[1]; 7 } 8 return obj[key]; 9 } 调用: 1 alert(getC

javascript设置和获取cookie值

//设置cookie function setCookie(name,value,expires,path,domain,secure){ var cookieName = encodeURIComponent(name) + '=' + encodeURIComponent(value); if(expires instanceof Date){ cookieName += ';expires=' + expires; } if(path){ cookieName += ';path=' +

jQuery获取cookie

之前一直以为获取cookie的方法封装在了jQuery包中...没想到还得单独下jquery.cookie.js插件,不太好找,备份一份: /*! * jQuery Cookie Plugin v1.4.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Klaus Hartl * Released under the MIT license */ (function (factory) { if (typeof de

javascript设置和获取cookie的通用方法

//获取cookie  function getCookieValue(cookieName)  {     var cookieValue = document.cookie;     var cookieStartAt = cookieValue.indexOf(""+cookieName+"=");     if(cookieStartAt==-1)     {         cookieStartAt = cookieValue.indexOf(cooki

PHP获取Cookie模拟登录

一.定义Cookie存储路径 必须使用绝对路径 $cookie_jar = dirname(__FILE__)."/pic.cookie"; //$cookie_file = dirname(__FILE__).'/cookie.txt'; //$cookie_file = tempnam("tmp","cookie"); 二.获取Cookie $url = "http://1.2.3.4/"; $ch = curl_init

php设置和获取cookie

setcookie('mycookie','value');//函数原型:int setcookie(string name,string value,int expire,string path,string domain,int secure)echo($mycookie);echo($HTTP_COOKIE_VARS['mycookie']);echo($_COOKIE['mycookie']); 删除Cookie(1)调用只带有name参数的setcookie();(2)使失效时间为ti