Objective
The goal is to provide features for inventory management for the authenticated users. Other visitors can consult the inventory only, and filter their findings.
Authentication
The authentication is through the ajaxSession()
javascript function as described here.
-
PHP / Ajax : How to show/hide DIV on $_SESSION variable value?
(See answer) PHP: $_SESSION doesn't seem to get set. Any idea?
Now, the $.ajax()
delegate gets the right answer from the PHP server. Now, I though of simply use CSS classes .hide
and .show
, but it doesn't seem to be a good idea for security reasons.
The
ajaxSession()
function
function ajaxSession(actionUrl) {
$.ajax(function() {
url: actionUrl
success: function(authenticated) {
if (authenticated == 'true') {
// create buttons here.
} else {
// ensure to empty those div
}
}
});
}
N.B. There are other members set in the $.ajax()
call, but the important is there.