Using sessions within PHP include file

Anyone know if you can save a session variable from a PHP include?

I have a Dashboard page which has header.php as a Wappler include. In my header.php file, I have a log out button which on click is supposed to save a new session called loggedout=true and then redirect to login.php page.

The redirect is working fine but for some reason the session is not saving. I’ve copied the exact same session in to a standard php file to test and that is working fine.

Unless someone knows otherwise, it appears that saving a session or cookie does not work from an include.

Can you explain a little more here?

Have you just applied the set session action on click, when this button is also used to run the logout action?

Originally I set the on click to set session action and then redirect. I also tried deleting redirect and running just the session action but no luck. Checked in Chrome developer tools and no session is being saved.

Can you paste the button code here, please?

Sign out link:

<div class="dropdown-item" dmx-on:click="signout.load({})" style="cursor:pointer;"><span class="dropdown-icon oi oi-account-logout"></span> Sign Out</div>

Server action:

<dmx-serverconnect id="signout" url="dmxConnect/api/security/signout.php" noload="noload" dmx-on:success="session1.set('test','testing',{});browser.goto('/login?signout=true')"></dmx-serverconnect>

Can you please provide a link to your page where we can check this?
You can send it to me as a personal message.

you are using on success event try “start” event …