Remove All Session Values

I want to remove all session variables on a button click.
the way i can see right now is to session1.remove('variableName'). but this means that i have to set this 25 times, for each of my 25 session variables.

is there an easier way to clear session fully with a single command?

Hello @nshkrsh

There isnt session destroy all function in wappler like php or other languages (session_destroy() )but you can try;

Create server connect action then write all sessions (use remove session)

And add it to your page then you can call it with one click

1 Like

i tried this with one session variable but it did not work:

can you please help me to make it work?

session name: session1
variable name: cecclientid
variable type: text

please try @nshkrsh

@Teodor Can you please help me understand the use of Set & Remove session in Server Action?
From the name of it, I assumed it would help me manage the session manager component created on the client side - and allow data to be accessible from both ends. But I have tried/tested it and it does not seem to work that way.
I am using .NET IIS.

Also, if the session works only on server side, does this mean the variables created are accessible across different server actions during a single user session?

1 Like

I think you are confusing client side sessions with server side session variables.
These are totally different things.

Browser/client side sessions live within the browser session and are available only client side. Managed with State Manager

Server side sessions live on server side only and are managed with server connect set/remove/get session variable action steps and also available only server side as $_SESSION. Available while the server user session is active.

Which ones are you using and exactly are you trying to achieve?

Ok… understood. They both are different, as I though.

I am using client side sessions. What I am trying to is achieve is two things:

  1. Remove values from all client side session (around 25) in simplest & fastest way possible. Setting each session variable as empty using session1.set('varname','',{}) is lot of code.
  2. Send more than 1 response from server action. The output of a server action can be only one. I need to send two kinds of values. For eg: an ID from database query, and response of API action.
    So I was hoping I could set the ID in a session, and let the API response be regular output.

Wow 25 client sessions :slight_smile: are you sure you need 25 session at all?
It’s currently not possible to remove all client side sessions, but probably we can add it in the dynamic events. @patrick can advise if that’s possible.

As for question 2 I am not really sure I understand your idea.

This is related to the SPA caching & server connect loading issue we were discussing in the other post. :sweat_smile:
There are probably just 5-7 sessions, rest are duplicates. Lets see if Patrick has something to clear it out.

I’ll give another example - In my server action I have a DB select query and an API action. I need to access both the results on client side.
Right now, I can retrieve only one of them on client-side.

I also did not understand what is this “caching” you were referring to in your other topic. It’s not good to use 25 sessions when you only need 5 …
Still waiting for a link to a sample page, with step by step explanation of how to reproduce this.

What do you mean? If both are outputted in the server action - what’s the issue to access them?

A bit busy sorting other issues. :sweat_smile: Will share ASAP.

I must be tripping. I am pretty sure I have tried this before, and the response was blank.
I tried it again now and its works fine! :smile: Thanks. :slight_smile:

1 Like

You want to clear all the session data from the browser? I could add a method for it in the State Manager component. You can do it in JavaScript with sessionStorage.clear(). Normally you don’t need to clear all sessions, this is automatically done when the browser is closed.

hello @Teodor

you said that "I think you are confusing client side sessions with server side session variables. "

is client side session secure ? and can you explain to us what is differencies clientside sessions …

Hello Serhat,

There are plenty of articles on this topic on the web, for example the w3schools is a nice learning resource, there are also others:

1 Like

Client-side sessions are stored in the browser storage, users can see what is in the session storage by using the Dev Tools. They are not being send to the server and only exist in the clients browser.

Server-side the sessions are stored on the server in a file, database or memory. The server sets a cookie with a unique id, this is used to get the users session data. The data stored in the session can only be read on the server using PHP/ASP.


thank you @patrick , @Teodor