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


C++ Cookie::isNull方法代码示例

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


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

示例1: getSessionFromAction

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

示例2: deleteCookie

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

示例3: deleteSession

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


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