How to terminate or logout ubus session?

I'm ubus, and I need to place a Logout button for web panel,
I've tried to use the below method to terminate a session, but it failed:

current session : 7e2cdc6a16e20b6c295affb867db82f6

ubus call session destroy {"ubus_rpc_session":"7e2cdc6a16e20b6c295affb867db82f6"}
Failed to parse message data

whats the best way to terminate ubus session,
please provide an example

ubus call session destroy '{ "ubus_rpc_session" : "492f028bbb25b7b3de650a4d5682def4" }'

https://openwrt.org/docs/techref/ubus

@anon50098793

thank you its working,

how to use that inside jsonrpc?

curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "492f028bbb25b7b3de650a4d5682def4", "session", "destroy", '{ "ubus_rpc_session" : "492f028bbb25b7b3de650a4d5682def4" }' ] }'  http://192.168.1.1/ubus

{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}

something goes wrong

@jow
Can you plz give me the right request for jsonrpc ?

  • ubus_rpc_session is always implicitly passed to invoked functions
  • You need to pass the argument to the method as JSON object, not as a string containing JSON
curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "492f028bbb25b7b3de650a4d5682def4", "session", "destroy", {} ] }'  http://192.168.1.1/ubus

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.