PHP: $_SESSION destroyed after page reload for my custom session

Viewed 35

I have develop a plugin for customer portal. For check login I have use custom session. Few month ago I have face this issue which create for session_start() function and I have already fix this.

Now I am facing same issue which create for wp "Login Designer" plugin. I have install this plugin in my website. When I enable Google Recaptcha v3(see the attachment), my custom session does not work. After check auth, data stored in $_SESSION['custom_session'] but after redirect to dashboard $_SESSION['custom_session'] data destroyed and it's redirect to login page again.

Note : It work if I logged-in in wp-admin.

enter image description here

Anyone know about this issue?

Thanks in advance.

1 Answers

As per the documentation WordPress mostly use cookies to store session data and if you want to access the dashboard you have to go with WordPress authentication by using hooks and filters. If you want to make some authentication on custom templates then use this hook Reason: By default session is not started in wordpress you have to start it. for more information read this

function start_custom_session() {
    if(!session_id()) {
        session_start();
    }
}

add_action('init', 'start_custom_session', 1);

Related