Symbian3/SDK/Source/GUID-00552575-AB10-4CB3-A37B-D83AE5975811.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-00552575-AB10-4CB3-A37B-D83AE5975811" xml:lang="en"><title>HTTP
session ID</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>HTTP session ID is an optional non-negative integer which is attached to
the session and any sockets it creates. The session ID is set on sockets by
using <xref href="GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0.dita#GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0/GUID-0DD7A667-7043-3D6B-A086-32DD222C199B"><apiname>RSocket::SetOpt()</apiname></xref>. </p>
<p>With this session ID, clients can specify an integer ID for an HTTP session,
which is assigned to subsequent sockets. An ID that is set applies to subsequent
socket connections. </p>
<p>HTTP session ID can be accessed using a Flow hook implementing the <codeph>SetFlowOption()</codeph> method,
which is called whenever <xref href="GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0.dita#GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0/GUID-0DD7A667-7043-3D6B-A086-32DD222C199B"><apiname>RSocket::SetOpt()</apiname></xref> is called. The
Flow hook helps determine if a socket came from a specific session. </p>
<p>The session ID is set when the socket is created and is not changed. To
find the session ID of a socket, the flow object must look for Set Option
commands that request setting session ID. The ID that is set can be saved
in the Flow hook object, and used later when needed. This can be done using
an <codeph>iSessionId</codeph> variable to hold the value, as shown in the
following example: </p>
<codeblock id="GUID-11827E76-ECD4-52E7-89B0-0152A4CF5A47" xml:space="preserve">#include &lt;HTTPSocketConstants.h&gt; // option consts defined here.... 
class CMip4Protocol : public CIp6Hook 
{ 
public: 
... 
virtual TInt SetFlowOption(TUint aLevel, TUint aName, const TDesC8 &amp;aOption, CFlowContext &amp;aFlow); 
private: 
...
TInt iSessionId; // session ID is stored here. Should be initialized to KErrNotFound
};</codeblock>
<p>The HTTP session ID, <codeph>HTTP::ESessionId</codeph>, when set, is accessed
using the session’s connection info object. For example: </p>
<codeblock id="GUID-E46A1152-E4CC-5FFE-8686-68605C6D4909" xml:space="preserve">RHTTPSession session;
...
RHTTPConnectionInfo ConnectionInfo = session.ConnectionInfo();
</codeblock>
<p>To access the value, <codeph>RString</codeph> must first be extracted from
the string pool. For example: </p>
<codeblock id="GUID-C833CEEC-A8E8-5687-8F47-C1836FCD0933" xml:space="preserve">RStringF sessionId = session.StringPool().StringF(HTTP::ESessionId, RHTTPSession::GetTable());
sessionId.Close();</codeblock>
</conbody></concept>