当前位置: 首页>>代码示例>>C++>>正文


C++ Cookie类代码示例

本文整理汇总了C++中Cookie的典型用法代码示例。如果您正苦于以下问题:C++ Cookie类的具体用法?C++ Cookie怎么用?C++ Cookie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cookie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(CookieDecoderTest, testDecodingWeirdNames2) {
    String src = "HTTPOnly=";
    Set<Cookie> cookies = CookieDecoder.decode(src);
    Cookie c = cookies.iterator().next();
    assertEquals("HTTPOnly", c.getName());
    assertEquals("", c.getValue());
}
开发者ID:1suming,项目名称:cetty2,代码行数:7,代码来源:CookieDecoderTest.cpp

示例2: Exception

bool SessionManager::getSessionFromAction(
   BtpAction* action, string& session, InternetAddress* ip)
{
   bool rval = true;

   // get client cookies
   CookieJar jar;
   jar.readCookies(action->getRequest()->getHeader(), CookieJar::Client);

   // check for bitmunk-session cookie
   Cookie cookie = jar.getCookie("bitmunk-session");
   if(cookie.isNull())
   {
      ExceptionRef e = new Exception(
         "No 'bitmunk-session' cookie.",
         "bitmunk.webui.SessionManager.MissingCookie");
      e->getDetails()["missingCookie"] = "bitmunk-session";
      Exception::set(e);
      rval = false;
   }
   else
   {
      // get session ID
      session = cookie["value"]->getString();
   }

   if(rval)
   {
      // get IP
      rval = action->getClientInternetAddress(ip);
   }

   return rval;
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:34,代码来源:SessionManager.cpp

示例3: while

BOOL CookiePath::CleanSmartCardAuthenticatedCookies()
{
	Cookie *next_ck = (Cookie *) cookie_list.First();

	while(next_ck )
	{
		Cookie *ck = next_ck;
		next_ck =  next_ck->Suc();

		if(ck->GetHaveSmartCardAuthentication())
		{
			OP_DELETE(ck);
		}
	}

	CookiePath *next_cp = LastChild();

	while(next_cp)
	{
		CookiePath *cp = next_cp;
		next_cp = next_cp->Pred();

		if(cp->CleanSmartCardAuthenticatedCookies())
		{
			cp->Out();
			OP_DELETE(cp);
		}
	}

	return cookie_list.Empty() && Empty();
}
开发者ID:prestocore,项目名称:browser,代码行数:31,代码来源:url_cmp.cpp

示例4: main

int main()
{
	while (FCGI_Accept() >= 0)
    {
		webapp::g_out = "";
		//输出header
		webapp::http_head();
		
		Cgi cgi;
		
		string username = cgi["username"];
		string email = cgi["email"];
		string password = cgi["password"];
		
		Cookie cookie;
		
		DateTime now;
		DateTime expires = now + ( TIME_ONE_DAY*3 ); // Cookie有效期为三天
		cookie.set_cookie("usercookie", username, expires.gmt_datetime());
		
		string usercookie = cookie["usercookie"];
		
		stringstream ss;
		ss  <<"username: "<<username<<"\n"
			<<"email: "<<email<<"\n"
			<<"password: "<<password<<"\n"
			<<"usercookie: "<<usercookie<<"\n";
		
		webapp::g_out += ss.str();
					       		
		FCGI_printf("%s",webapp::g_out.c_str());
    }
    return 0;
}
开发者ID:zhihaibang,项目名称:benson-style,代码行数:34,代码来源:fcgi.cpp

示例5: nfs4_close_dir

static status_t 
nfs4_close_dir(fs_volume* volume, fs_vnode* vnode, void* _cookie)
{
	TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p", volume,
		reinterpret_cast<VnodeToInode*>(vnode->private_node)->ID(), _cookie);

	Cookie* cookie = reinterpret_cast<Cookie*>(_cookie);
	return cookie->CancelAll();
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: LocalGetCookie

Cookie* CookiePath::LocalGetCookie(const OpStringC8 &nme)
{
	if (nme.IsEmpty())
		return 0;

	Cookie* ck = (Cookie*) cookie_list.First();
	while (ck && ck->Name().Compare(nme) != 0)
		ck = ck->Suc();

	return ck;
}
开发者ID:prestocore,项目名称:browser,代码行数:11,代码来源:url_cmp.cpp

示例7:

Cookie& HttpHeader::getCookie(const string &key)
{
	auto cookieIt = _cookies.find(key);
	if (cookieIt != _cookies.end()) {
		return cookieIt->second;
	}

	Cookie cookie;
	cookie.setKey(key);
	_cookies[key] = cookie;

	return _cookies[key];
}
开发者ID:rafaeljusto,项目名称:CGIplus,代码行数:13,代码来源:HttpHeader.cpp

示例8: getCookie

void CookieJar::deleteCookie(const char* name, bool secure)
{
    Cookie cookie = getCookie(name);
    if(cookie.isNull())
    {
        setCookie(name, "", 0, secure, false);
    }
    else
    {
        cookie["value"] = "";
        cookie["maxAge"] = 0;
        cookie["httpOnly"] = true;
    }
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:14,代码来源:CookieJar.cpp

示例9: Cookie

void Handshake::createCookie(PacketWriter& writer,HelloAttempt& attempt,const string& tag,const string& queryUrl) {
	// New Cookie
	Cookie* pCookie = attempt.pCookie;
	if(!pCookie) {
		if(attempt.pTarget)
			pCookie = new Cookie(*this,invoker,tag,*attempt.pTarget);
		else
			pCookie = new Cookie(*this,invoker,tag,queryUrl);
		_cookies[pCookie->value()] =  pCookie;
		attempt.pCookie = pCookie;
	}
	writer.write8(COOKIE_SIZE);
	writer.writeRaw(pCookie->value(),COOKIE_SIZE);
}
开发者ID:null-null-cn,项目名称:Cumulus,代码行数:14,代码来源:Handshake.cpp

示例10: sizeof

void CookiePath::GetMemUsed(DebugUrlMemory &debug)
{
	debug.memory_cookies += sizeof(*this) + path.Length();

	Cookie *ck = (Cookie *) cookie_list.First();
	while(ck)
	{
		ck->GetMemUsed(debug);
		ck = ck->Suc();
	}

	CookiePath *cp = (CookiePath *) FirstChild();
	while(cp)
	{
		cp->GetMemUsed(debug);
		cp = cp->Suc();
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:18,代码来源:url_cmp.cpp

示例11: fprintf

void CookiePath::DebugWriteCookies(FILE* fp)
{
	fprintf(fp, "   ");
	DebugWritePath(fp);
	fprintf(fp, ": \n");
	Cookie* ck = (Cookie*) cookie_list.First();
	while (ck)
	{
		fprintf(fp, "      %s=%s; %lu; %d; %lu %s\n", ck->Name(), ck->Value(), ck->Expires(), ck->Secure(), ck->GetLastUsed(), (ck->DiscardAtExit() ? "; Discard on exit" : ""));
		ck = ck->Suc();
	}

	CookiePath* cp = (CookiePath*) FirstChild();
	while (cp)
	{
		cp->DebugWriteCookies(fp);
		cp = cp->Suc();
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:19,代码来源:url_cmp.cpp

示例12: strcmp

void SessionManager::deleteSession(BtpAction* action)
{
   // read session cookie from request header
   CookieJar jar;
   HttpHeader* header = action->getRequest()->getHeader();
   jar.readCookies(header, CookieJar::Client);
   Cookie cookie = jar.getCookie("bitmunk-session");
   if(!cookie.isNull())
   {
      // get session value
      const char* session = cookie["value"]->getString();

      // lock to modify sessions
      mSessionLock.lock();
      {
         // ensure the session is valid before removing it from the session
         // manager (which is different from simply deleting the cookies on
         // the client ... which is always permitted)
         SessionMap::iterator i = mSessions.find(session);
         if(i != mSessions.end())
         {
            InternetAddress ip;
            if(action->getClientInternetAddress(&ip) &&
               strcmp(ip.getAddress(), i->second.ip.c_str()) == 0)
            {
               // session valid, IP matches, so remove it
               const char* tmp = i->first;
               mSessions.erase(i);
               free((char*)tmp);
            }
         }
      }
      mSessionLock.unlock();
   }

   // delete cookies in response header
   jar.deleteCookie("bitmunk-session", COOKIES_SECURE);
   jar.deleteCookie("bitmunk-user-id", COOKIES_SECURE);
   jar.deleteCookie("bitmunk-username", COOKIES_SECURE);
   header = action->getResponse()->getHeader();
   jar.writeCookies(header, CookieJar::Server, false);
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:42,代码来源:SessionManager.cpp

示例13: structNewCookie

	CGI* CGI::addCookie(QString strName, QString strValue, QDateTime qdtExpiration, QString strDomain, QString strPath, bool bHttpOnly, bool bSecure) {
		// Iterate over the existing new cookies
		for (int intCookie = 0; intCookie < this->mNewCookies.size(); ++intCookie) {
			// Localize the cookie
			Cookie structNewCookie = this->mNewCookies.at(intCookie);
			// Check the name
			if (structNewCookie.getName() == strName) {
				// Delete the cookie
				this->mNewCookies.removeAt(intCookie);
				// We're done
				break;
			}
		}
		// Create the new structure
		Cookie structNewCookie(strName, strValue, qdtExpiration, strDomain, strPath, bHttpOnly, bSecure);
		// Add the cookie to the instance
		this->mNewCookies.append(structNewCookie);
		// Return the instance
		return this;
	}
开发者ID:bolvarak,项目名称:HeimdallGI,代码行数:20,代码来源:CGI.cpp

示例14: nfs4_close

static status_t
nfs4_close(fs_volume* volume, fs_vnode* vnode, void* _cookie)
{
	VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(vnode->private_node);

	TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p", volume, vti->ID(),
		_cookie);

	VnodeToInodeLocker _(vti);
	Inode* inode = vti->Get();
	if (inode == NULL)
		return B_ENTRY_NOT_FOUND;


	if (inode->Type() == S_IFDIR || inode->Type() == S_IFLNK)
		return B_OK;

	Cookie* cookie = reinterpret_cast<Cookie*>(_cookie);
	return cookie->CancelAll();
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例15: xml

XtrazRequestPacket::XtrazRequestPacket(IcqContact *contact, const QString &query, const QString &notify)
{
	QString body;
	{
		QXmlStreamWriter xml(&body);
		xml.writeStartElement("N");
		xml.writeStartElement("QUERY");
		xml.writeCharacters(query);
		xml.writeEndElement();
		xml.writeStartElement("NOTIFY");
		xml.writeCharacters(notify);
		xml.writeEndElement();
		xml.writeEndElement();
	}
	XtrazData data(body);
	Cookie cookie = data.cookie();
	cookie.setContact(contact);
	setCookie(cookie);
	init(contact, 2, cookie);
	appendTLV(0x05, Channel2MessageData(1, data).data());
	appendTLV(0x03);
}
开发者ID:Anderty,项目名称:qutim,代码行数:22,代码来源:xtraz.cpp


注:本文中的Cookie类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。