The following example demonstrates how to retrieve the value of variable stored in the Session object.
STDMETHODIMP CHowtos1::OnStartPage (IUnknown* pUnk) { HRESULT hr; IScriptingContext *piContext; //Get IScriptingContext Interface hr = pUnk->QueryInterface(IID_IScriptingContext, (void**)&piContext); //Get Response Object Pointer IResponse* piResponse = NULL; hr = piContext->get_Response(&piResponse); //Create a VARIANT to receive the Session Variable's Value VARIANT vtOut; VariantInit(&vtOut); //Get Session Object Pointer ISessionObject *piSession = NULL; hr = piContext->get_Session(&piSession); //Get the Value for Session Variable "Var1" hr = piSession->get_Value(OLESTR("Var1"), &vtOut); //Write the value of Var1 to the HTML page piResponse->Write(vtOut); //Release Interface Pointers piSession->Release(); piResponse->Release(); piContext->Release(); return S_OK; }