I'd like to build a site that has only HTML/jQuery in the frontend and PHP/MySQL in the backend.
How can I manage the user sessions (login/logout) and work with session variables using only HTML/jQuery?
Thanks
I'd like to build a site that has only HTML/jQuery in the frontend and PHP/MySQL in the backend.
How can I manage the user sessions (login/logout) and work with session variables using only HTML/jQuery?
Thanks
Using jQuery you could perform AJAX calls to a page in php with method to login, logout and query for session variables.
Also. If your app is not working with server at regultar intervals make request to server to keep session alive.
Login example
JQuery
$.ajax({
dataType: "json",
url: "http://yoursite.com/ajax.php?method=login",
data: yourloginData,
success: yourSuccesAction
});
PHP
<?php
if(isset($_GET['method']){
if ($_GET['method'] == 'login'){
// do login here and print response to server
// for example in json with json_encode
}
}
More information see: