+QNetworkCookie* CookiesDatabase::getCookieById(const int &id)
+{
+ // Get a handle for the cookies database.
+ QSqlDatabase cookiesDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+ // Instantiate a cookie query.
+ QSqlQuery cookieQuery(cookiesDatabase);
+
+ // Set the query to be forward only.
+ cookieQuery.setForwardOnly(true);
+
+ // Prepare the cookies query.
+ cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + _ID + " = :id");
+
+ // Bind the values.
+ cookieQuery.bindValue(":id", id);
+
+ // Execute the query.
+ cookieQuery.exec();
+
+ // Move to the first entry.
+ cookieQuery.first();
+
+ // Create a cookie.
+ QNetworkCookie *cookiePointer = new QNetworkCookie();
+
+ // Populate the cookie.
+ cookiePointer->setDomain(cookieQuery.value(DOMAIN).toString());
+ cookiePointer->setName(cookieQuery.value(NAME).toString().toUtf8());
+ cookiePointer->setPath(cookieQuery.value(PATH).toString());
+ cookiePointer->setExpirationDate(QDateTime::fromString(cookieQuery.value(EXPIRATION_DATE).toString(), Qt::ISODate));
+ cookiePointer->setHttpOnly(cookieQuery.value(HTTP_ONLY).toBool());
+ cookiePointer->setSecure(cookieQuery.value(SECURE).toBool());
+ cookiePointer->setValue(cookieQuery.value(VALUE).toString().toUtf8());
+
+ // Return the cookie.
+ return cookiePointer;
+}
+