mgd_auth_midgard

(Midgard 1.4.2 'Bifrost')

mgd_auth_midgard -- Authenticate a user

Description

bool mgd_auth_midgard (string username, string password, boolean [sendcookie])

Minimum version: Midgard 1.2.5 (Mad King) -- sendcookie from: Midgard 1.4 (Bifrost)

When called the user will be sent a cookie named MidgardLogin that contains the username and cleartext password. Be aware of one serious issue with cookies: many client machines are not secured (physically or otherwise) and the cookie files are easily accessible.

You can use this function to offer logins by means of an HTML form instead of the popup window many browsers present when asked for HTTP authentication credentials. The Midgard code will not see the difference between a user logged in by HTTP authentication or the cookie login (although you can examine the MidgardLogin cookie to see if it's been set). If the optional sendcookie parameter has been set to zero (FALSE), Midgard will only authenticate the user for that particular page, and will not send an authentication cookie to the browser. Please note that this third optional parameter is only available in Midgard 1.4 (Bifrost) and later versions.

Warning

You should call this function before any content is sent. This function will silently fail if called after.

Returns TRUE if successful. Returns FALSE on failure.