Dynamic login/logout in nav bar ssi php includee

Hi, sorry I know this has sort of been posted before, but I still cannot find the answer or a working solution, I admit I am a real newbie to Wappler but don’t want to give up on what seems such a brilliant app because I cannot make something work.

I followed the videos for building a basic system to create a user account, login, logout, that all works (initially).

I then setup a navbar and this has the logout button. I moved the navbar to a ssi php include. The navbar displays just fine.

On my dashboard page I have teh user_logout server connect and the browser bit setup, so the dashboard logout button works.

but, if I am on say the newuser page, the logout button does not work. I didnt want to add browser and user_logout to every single page, so, I tried adding the user_logout server connect and browser bits to the navbar.php ssi. But that just does not seem to work, is that because is uses the on success goto command but the headers have already been set at this point?

I basically want the logout button to work on all pages.

to confuse things further, I really want the logout button to be replaced with a login button if they log out, but can not get that working, I have a user_data_query that shows the userid etc, and have tried a dynamic attributes -> show -> user_data:ID but I always get the logout button, it disappears from the wappler design view of the navbar page but not when run through a browser when the page is a complete page.

I have wastched every video I can find, read every tutorial I can get my hands on but none seem to show a dynamic login/logout setup with the navbar in an SSI - which I assume most people would do for maintainability?

Sorry for my first long winded post, I hope it makes sense and can find an answer, I see other people asking the same but doesnt look like they got the right reply either from what I read, some threads just died.

All the best
Darren

I’ve successfully added login/logout functionality to the header include (see aircrewaccommodation.com for an example). I put the server connect in the included file (I call mine _header.php) and Wappler is smart enough to make the data available in the bindings on any page which has the included file. I just set the show or hide attributes based on whether they are logged in or not.

thanks for your reply, nice site. I got mine finally working just this minute, i stripped the logout server connect from pages and the browser app from pages and put both those purely in the ssi and now it works, button disappears when not logged in and logout works on all pages, so think it was just having the code in the pages and not the navbar ssi and then in both messing around trying to get it to work. I now get a 401 not authorized on my login page but I saw other people had that as well and the consensus was that was not a problem, as its doing a check to see if they are logged in so its not authorized, i would have thought a session check might be better but i cant work out sessions yet, how to get those available on the app side and what to setup on the server connect side

thanks

Glad you got it working.

Maybe remove the Security Restrict from the login page? There doesn’t need to be any security checks on that page, I wouldn’t have thought.