MapGuide API Reference
 All Classes Functions Variables Enumerations Enumerator Friends

Creates a session repository for the current user.

Remarks:
Resources placed into the session repository will exist until the session expires or the session is destroyed by using DestroySession. The session repository is tied exclusively to the user, and can be used, for example, to store temporary layers.
You can use the session identifier to tie a web tier application session to the stored data. You can use standard web tier session mechanisms like client side cookies, hidden form fields, and additional URL parameters on dynamically generated web pages to propagate the identifier from one page to another.
For the lifetime of the session, the session identifier can also be used to reauthenticate with the MapGuide site.
.NET Syntax
string CreateSession();
Java Syntax
String CreateSession();
PHP Syntax
string CreateSession();
Returns:
The session identifier, for example "71b5d990-0000-1000-8000-005056c00008_eng".
Examples (PHP)
This example shows how to create a session repository. Note how the session ID is stored back in the MgUserInformation object. This is necessary for GetCurrentSession to work.

 // Initialize the web tier
 MgInitializeWebTier('C:\Inetpub\wwwroot\PhpMapAgent\webconfig.ini');

 // Establish a connection to a site.
 $userInformation = new MgUserInformation('Administrator', 'admin');
 $siteConnection = new MgSiteConnection();
 $siteConnection->Open($userInformation);

 // Create a session repository
 $site = $siteConnection->GetSite();
 $sessionID = $site->CreateSession();
 $userInformation->SetMgSessionId($sessionID);

This example shows how to reauthenticate using the session ID:

 // Assuming this page was called by
 // <A href="page_two.php?sessionId=<?= $site->GetCurrentSession(); ?>">Page Two</A>
 $userInformation = new MgUserInformation($_GET['sessionId']);

This example shows how to enumerate the resources in the session repository:

 $sessionName = "Session:$sessionID//";
 $resourceID = new MgResourceIdentifier($sessionName);
 $byteReader = $resourceService->EnumerateResources($resourceID, -1, "");
Exceptions:
[[Tobe documented]]
See also:
DestroySession
GetCurrentSession