wordpress losing the session on page refresh

I’m trying to develop a plugin for the wordpress and i’m having a small issue with the session. I have created my own login page for my plugin and when user puts his username/password and press the login button an ajax request sends the data to a function to check if user details are correct or not. The function that the ajax is calling is stored inside my index.php of my plugin. Using the $_SESSION in the function that ajax is calling, i can print the variable that I want,which has been set inside another file. Then if the data are correct the ajax reloads the page. When the page is been reloaded the session no more exist. Does anyone knows how i can solve this problem? I implemented the plugin on a localserver which was working fine, but when i uploaded the project on a subdomain on a server, it stopped to working.

AJAX code

Read More
    success: function(data) {
        console.log(data);
        if (data !='')
        {
            var obj = $.parseJSON(data);
            if (obj.status == "ok")
            {
                location.reload();
            }
        }

Thank you

Related posts

Leave a Reply

1 comment

  1. Have you tried using the .RememberState function with your ajax call? Typically this might be applied to a form (so if the form is partially filled out and a user refreshes the page their changes are preserved), but in theory I don’t see why you couldnt use it on the document itself. Check out this link it might explain it more clearly

    http://shaneriley.com/jquery/remember_state/

    You’d want to do this before the call, and in the success callback, you should be able to use this RememberState to return to the active session you had before. If this isn’t what you’re referring to I apologize for misinterpreting your question.