Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CInternetSession Class

Creates and initializes a single or several simultaneous Internet sessions and, if necessary, describes your connection to a proxy server.

class CInternetSession : public CObject

Name

Description

CInternetSession::CInternetSession

Constructs a CInternetSession object.

Name

Description

CInternetSession::Close

Closes the Internet connection when the Internet session is terminated.

CInternetSession::EnableStatusCallback

Establishes a status callback routine.

CInternetSession::GetContext

Closes the Internet connection when the Internet session is terminated.

CInternetSession::GetCookie

Returns cookies for the specified URL and all its parent URLs.

CInternetSession::GetCookieLength

Retrieves the variable specifying the length of the cookie stored in the buffer.

CInternetSession::GetFtpConnection

Opens an FTP session with a server. Logs on the user.

CInternetSession::GetGopherConnection

Opens a gopher server for an application that is trying to open a connection.

CInternetSession::GetHttpConnection

Opens an HTTP server for an application that is trying to open a connection.

CInternetSession::OnStatusCallback

Updates the status of an operation when status callback is enabled.

CInternetSession::OpenURL

Parses and opens a URL.

CInternetSession::SetCookie

Sets a cookie for the specified URL.

CInternetSession::SetOption

Sets options for the Internet session.

Name

Description

CInternetSession::operator HINTERNET

A handle to the current Internet session.

If your Internet connection must be maintained for the duration of an application, you can create a CInternetSession member of the class CWinApp.

Once you have established an Internet session, you can call OpenURL. CInternetSession then parses the URL for you by calling the global function AfxParseURL. Regardless of its protocol type, CInternetSession interprets the URL and manages it for you. It can handle requests for local files identified with the URL resource "file://". OpenURL will return a pointer to a CStdioFile object if the name you pass it is a local file.

If you open a URL on an Internet server using OpenURL, you can read information from the site. If you want to perform service-specific (for example, HTTP, FTP, or gopher) actions on files located on a server, you must establish the appropriate connection with that server. To open a particular kind of connection directly to a particular service, use one of the following member functions:

SetOption allows you to set the query options of your session, such as time-out values, number of retries, and so on.

CInternetSession member functions SetCookie, GetCookie, and GetCookieLength provide the means to manage a Win32 cookie database, through which servers and scripts maintain state information about the client workstation.

For more information about basic Internet programming tasks, see the article Internet First Steps: WinInet. For general information about using the MFC WinInet classes, see the article Internet Programming with WinInet.

Note Note

CInternetSession will throw an AfxThrowNotSupportedException for unsupported service types. Only the following service types are currently supported: FTP, HTTP, gopher, and file.

Header: afxinet.h

Show:
© 2015 Microsoft