Skip to content

Sessions

Charly edited this page Feb 19, 2022 · 4 revisions

mh_SessionInit()

mh_SessionInit( cNamespace, nExpired )

cNamespace ➜ Optional parameter, default empty. You can define a space for all your variables. By default variables are stored in a non-namespaced location. It's interesting if you want to use more than one application and each one has its environment variables, for example mh_SessionInit( 'My_App_A' ).

nExpired ➜ Optional parameter. Duration of a session. By default it has a value of 3600 seconds

mh_SessionInit()

Sessions are used in many languages and allow variables to be temporarily stored on the server and retrieved in another executed request.

Code example | Demo

mh_Session()

mh_Session( cKey, uValue )

cKey ➜ Parameter name

uValue ➜ Optional parameter. If you specify this parameter it will store its value in the cKey variable. If nothing is specified, it will retrieve the value of cKey

mh_Session( 'name', 'Marian Fletcher')

It's the typical setter/getter function that will allow us to manage the variables in each session

Code example | Demo

mh_SessionEnd()

mh_SessionEnd( cNamespace )

cNamespace➜ Optional parameter

mh_SessionEnd()

Very important function to execute when we no longer need to handle our session variables. This function deletes all its content from the server and it can no longer be accessed. In the case of not closing the session, it will be automatically destroyed by the mod's internal collector when it expires.

Code example | Demo

Clone this wiki locally