php到Ajax会话和返回

I have a webpage that currently just uses one main php page that uses Ajax to change the state of a div between the contents of several other php files.

I think I need to pass a session state (that holds the current state of a webpage) into the ajax script that switches between different pages via a navigation bar.

PHP:

<?php
    session_save_path("sess");
    session_start();

    if(!isset($_SESSION['state'])){
        $_SESSION['state'] = 'login.php';
    }
?>

Ajax:

<script>
    $(document).ready(function(){

        $("#disp").load("login.php");
        $("#nav1").click(function(){
            $("#disp").load("login.php");
        });
        $("#nav2").click(function(){
            $("#disp").load("registration.php");
        });
        $("#nav3").click(function(){    
            $("#disp").load("phppsql.php");
        });
    });
</script>

In the end I want the Ajax script to set the new state of the website from the click functions.

I've looked around and it seems JSON will be the answer, however I'm unsure about JSON syntax.

More specifically: is something like this legal?

echo json_encode($_SESSION['state']);

Thanks in advance.