'Ajax not properly sending Session variables

I am very new to AJAX and PHP and am currently working on a small website where I initialize php objects as session variables. The functions and objects are all workable in php and compiled with SWIG. When I try to access these variables after calling AJAX, the integer that I send over works well. However, the object that I send over gets set to 0. Below is my code, any advice or help is greatly appreciated. Thank you!

Below is the code that displays the website: index.php

<?php
session_start();
$_SESSION['w_id'] = 1;
$_SESSION['wordSet'] = init_WordSet(2234);

?>

<html>
        <head>   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><head>

        <body>
                <form method="get" class="ajax">
                        <input type="text" name="w_str">
                        <input type="submit">
                </form>
                <script>
                        $('form.ajax').on('submit', function(e){
                                e.preventDefault();
                                //Issue: How to get the input from php?
                                $.ajax({
                                        type: "GET",
                                        url: 'includes/functions.php',
                                        data: ({w_str: 'data'}),
                                        success: function(result){
                                                alert(result);
                                        }

                                });

                        });
                </script>




        </body>


</html>

Below is the php code that Ajax calls

<?php

        session_start();
        echo $_SESSION['w_id'] . ' ' . $_SESSION['wordSet'];
?>

The code for initializing the word set

struct WordSet* init_WordSet(int totalWords){
    //the total number of word blocks
    int arrLength = ceil((double)totalWords / (double)(sizeof(unsigned long) * NUM_BYTES));

    //the hash set that contains whether all words have been, or have not been used 
    struct WordSet *wordSet = malloc(sizeof(struct WordSet));
    wordSet->words = calloc(arrLength, sizeof(unsigned long)); 
    int i; 
    for(i = 0; i < arrLength; i++){
        //setting all the words to be unused
        wordSet->words[i] = 0; 
    }
    wordSet->totalWords = totalWords; 
    return wordSet; 
    
}```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source