How to store and retrieve session value through jquery?

1

I'm developing a mobile application with intel XDK I have to make a login that will be validated by the php file that contains all the validations and finally stores in session the values I need user no I know and how can I retrieve these values to list on the next page when login is successful. if possible I would like you to indicate the best solution and a basis for how it can be done.

    
asked by anonymous 16.06.2015 / 21:32

1 answer

2

Php

// Antes faça toda a declaraçao da sessão
function getUserSession(){
    return json_encode($_SESSION["user"]);
}

// Verifica se o login foi executado
if($login){
    getUserSession();
}

JavaScript

$.post( "arquivo.php", { user: "John", password: "*****" }, function( data ) {
  console.log(data); // Retorna os dados da sessão do usuário logado, ou da falha na autenticação em formato jSon
}, "json");
    
16.06.2015 / 23:09