[mapguide-users] How to check if session is expired?

Jackie Ng jackie.ng at aecsystems.com.au
Wed Oct 4 05:56:22 EDT 2006


Should we be calling those 4 lines of code on a "regular" basis to prevent
session expiry?

Regards,

Jackie Ng

AEC Spatial Pty Ltd. / AEC Systems Pty Ltd.
SYDNEY - MELBOURNE - BRISBANE - PERTH - ADELAIDE - HOBART 

A.B.N: 32 075 809 451

Level 4, 37-41 Prospect St. Box Hill, Victoria, 3128

Phone: 1300 368 609 
Fax:    1300 362 140 

www.aecsystems.com.au 
jackie.ng at aecsystems.com.au


-----Original Message-----
From: Trevor Wekel [mailto:trevor.wekel at autodesk.com] 
Sent: Friday, 29 September 2006 2:30 AM
To: François Van Der Biest; users at mapguide.osgeo.org
Cc: jackie.ng at aecsystems.com.au
Subject: RE: [mapguide-users] How to check if session is expired?

Hi Francois,

The Web Extension does not actively maintain the sessionId.  It has to be
created or set through script.  On application startup, you will always need
to create a new session using CreateSession() as below.  However, it is
possible to reuse a previously created session if you maintain the sessionId
in PHP.  The script you gave below will do this since you are using the PHP
session variable $_SESSION['mgSessionId'].  All you need to do is modify
your startup script to use $_SESSION['mgSessionId'] if it exists:

$userinfo = new MgUserInformation();
$userinfo->SetMgSessionId($_SESSION['mgSessionId']);
$site=new MgSite();
$site->Open($userinfo);

As long as you regularly access MapGuide with the sessionId, the session
will not expire.  However, you may need to increase the session timeout in
the Server configuration if your app has long periods of inactivity.

Thanks,
Trevor  


-----Original Message-----
From: François Van Der Biest [mailto:francois.van-der-biest at onf.fr]
Sent: Thursday, September 28, 2006 3:22 AM
To: users at mapguide.osgeo.org
Cc: jackie.ng at aecsystems.com.au
Subject: Re: [mapguide-users] How to check if session is expired?

Jackie Ng a écrit :
>  
> Hi François
>
> Thanks for the suggestion, I have since found out an easier way, to 
> check the length of MgSite.GetCurrentSession() as it will return an 
> empty string if expired.
>   

Strange thing : the result of MgSite.GetCurrentSession() is always empty in
my case (MGE 2007).
Has anyone ever experienced this ?

> But now when I try to access my map with this newly generated session 
> id. I get "Resource not found" errors. I thought that session 
> resources would be automatically created with the new session as 
> stated in the API docs. (???)
>   
We now share the same concern about this point.
Moreover, I 'd like to know if one always has to create a new session each
time the application is started (by the same person on the same machine), or
if one could re-use pre-existing session.

For instance, I'd like to do something like this, at application startup :

$userinfo=new MgUserInformation("Anonymous","");
$site=new MgSite();
$site->Open($userinfo);
if (strlen($site->GetCurrentSession())==0)
    $_SESSION['mgSessionId'] = $site->CreateSession(); else
    $_SESSION['mgSessionId'] = $site->GetCurrentSession();

... but the fact that GetCurrentSession always returns an empty string
prevents me from trying such a thing.

> I ask this question because I have actually tried bumping up the 
> session expiry time in the MapGuide Site admin, and it didn't seem to 
> make any difference :(
Same problem. Did you get any solution in the mean time ?

I'm beginning to be fed up with this problem...

F.





More information about the Mapguide-users mailing list