Export (0) Print
Expand All

IXMLHTTPRequest2::SetCookie method

Sets a cookie associated with the specified URL in the HTTP cookie jar.

Syntax


HRESULT SetCookie(
  const XHR_COOKIE *pCookie,
  DWORD *pdwCookieState
);

Parameters

pCookie

A pointer to an XHR_COOKIE structure that specifies the cookie and properties of the cookie to be associated with the specified URL.

pdwCookieState

A pointer to a value that indicates the cookie state if the call completes successfully.

This parameter can be one of the values from the XHR_COOKIE_STATE enumeration type defined in the Msxml6.h header file.

ValueMeaning
XHR_COOKIE_STATE_UNKNOWN
0

Reserved.

XHR_COOKIE_STATE_ACCEPT
1

The cookie was accepted.

XHR_COOKIE_STATE_PROMPT
2

The user is prompted to accept or refuse the cookie.

XHR_COOKIE_STATE_LEASH
3

The cookie is accepted only in the first-party context.

XHR_COOKIE_STATE_DOWNGRADE
4

The cookie was accepted and became session cookie.

XHR_COOKIE_STATE_REJECT
5

The cookie was rejected.

 

Return value

Returns S_OK on success.

Remarks

The SetCookie method has different behavior for Windows Store apps and desktop applications.

When used in a Windows Store app, the SetCookie method by default sets the cookie as a persistent cookie in the Windows Store app. When the dwFlags member of the XHR_COOKIE has the XHR_COOKIE_IS_SESSION flag set, then the cookie is set only for the current session of the app.

When used in a desktop application, the SetCookie method by default sets a persistent cookie that is system wide and shared by all desktop applications. When the dwFlags member of the XHR_COOKIE has the XHR_COOKIE_IS_SESSION flag set, then the cookie is set only for the current session of the desktop application.

Requirements

Minimum supported client

Windows 8 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2012 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Version

MSXML 6.0 and later

Header

Msxml6.h

IDL

Msxml6.idl

See also

GetCookie Method
XHR_COOKIE Structure
XHR_COOKIE_STATE
IXMLHTTPRequest2

 

 

Community Additions

ADD
Show:
© 2014 Microsoft