本文整理汇总了C++中HttpSession::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpSession::getId方法的具体用法?C++ HttpSession::getId怎么用?C++ HttpSession::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpSession
的用法示例。
在下文中一共展示了HttpSession::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startSession
HttpSession* SessionManager::startSession(const HttpRequest& request, HttpResponse& response) {
cleanUpOldSessions();
HttpSession* session = NULL;
if(mUseCookies) {
try {
const HttpCookie& sessionCookie = request.getCookie(mCookieName);
session = startSessionInternal(sessionCookie.getValue(), true, request, response);
} catch(const CookieNotFoundException& ex) {
}
}
if(!session && mUseRequest) {
try {
session = startSessionInternal(request.getAttribute(mRequestName), true, request, response);
} catch(const AttributeNotFoundException& ex) {
}
}
if(!session) {
session = startSessionInternal(generateSessionId(request, response), false, request, response);
}
if(mUseCookies && session) {
if(mCookieLifeTime > 0) {
response.addCookie(HttpCookie(mCookieName, session->getId(), mCookieLifeTime));
}
else {
response.addCookie(HttpCookie(mCookieName, session->getId()));
}
}
return session;
}
示例2: l
HttpSession& SessionManagerImpl::newSession(long maxInactiveInterval)
{
Mutex::ScopedLock l(_mutex);
HttpSession* ps = new HttpSessionImpl(maxInactiveInterval, _pSessionListener);
if(ps)
{
_sessionMap.insert(std::make_pair(ps->getId(), ps));
return *ps;
}
else throw NullPointerException("SessionManager::newSession");
}
示例3: removeSession
/** Delete a session */
void HttpSessionStore::removeSession(HttpSession session) {
mutex.lock();
sessions.remove(session.getId());
mutex.unlock();
}
示例4: doGet
void doGet(HttpServletRequest& req, HttpServletResponse &res) {
//dbg_stop();
res.setContentType("text/html");
ostream& out = res.getOutputStream();
out << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""
"\"http://www.w3.org/TR/html4/loose.dtd\">" << endl;
out << "<html><head><title>test</title></head><body>" << endl;
out << "PID: " << getpid() << "<hr>" << endl;
auto_ptr< vector<string> > names = req.getHeaderNames();
out << "<div style='border: solid black'>" << endl;
out << "Headers:<ul>" << endl;
for(unsigned i=0; i< names->size();++i) {
out << "<li>" << (*names)[i] << "<ul>";
auto_ptr< vector<string> > values = req.getHeaders((*names)[i]);
for(unsigned j=0; j < values->size();++j) {
out << "<li>" << (*values)[j] << "</li>";
}
out << "</ul>\n";
}
out << "</ul></div><br>\n";
out << "<div style='border: solid black'>" << endl;
out << "Cookies:<ul>" << endl;
auto_ptr< vector<Cookie> > cookies = req.getCookies();
for(unsigned i=0;i<cookies->size();++i)
out << "<li><u>" << (*cookies)[i].getName() << "</u> "
<< (*cookies)[i].getValue() << "</li>\n" << endl;
out << "</ul></div><br>\n";
out << "<div style='border: solid black'>" << endl;
out << "Parameters:<ul>" << endl;
names = req.getParameterNames();
for(unsigned i=0; i< names->size();++i) {
out << "<li>" << (*names)[i] << "<ul>";
auto_ptr< vector<string> > values = req.getParameterValues((*names)[i]);
for(unsigned j=0; j < values->size();++j) {
out << "<li>" << (*values)[j] << "</li>\n";
// Cookie c(names[i], req.getParameter(names[i]));
// res.addCookie(c);
}
out << "</ul>\n";
}
out << "</ul></div><br>";
HttpSession* session = req.getSession();
if(session){
int cnt;
if(session->isNew()){
cnt = 1;
session->setAttribute("cnt",cnt);
}else{
cnt = session->getAttribute<int>("cnt");
cnt++;
session->setAttribute("cnt",cnt);
}
out << "Your counter: " << cnt << endl;
out << "<br>ID: " << session->getId() << endl;
}else
out << "<h4>No session</h4>";
out << "</body></html>" << endl;
}