TypeError: $w(...)[data.command] is not a function

Sorry for the late answer, but as i can see Ahmad already have helped you.

How ever, it was a mess to give you the right answer! WHY ???

1) First learn to use this forum!
a) do not open multiple posts on (almost) the same topic/issue.
b) describe your situation as most detailed as possible, including all informations about your SETUP, your used Wix-Editor, ELEMENTS, IDs, DBs, DATASETs and so on…
c) Do not place CODE-PARTS into → PICs! Show codes inside a CODE-BLOCK!
d) Always be thankful and choose best answer and giving some likes :grin:

2) Use more the POWER of CONSOLE!
Observing all your generated codes → you did not used the CONSOLE consequently. The CONSOLE (especialy for you as beginner) is a LIFE-SAFER!!!

3) Do not expect that you will always get READY-2-GO-SOLUTIONS like this for free. (just a little start-up 4 you).

4) And here i provide you somethign of a combination of Ahmads and my own ideas and thoughts … (do not forget to take a look at all the given CONSOLE-LOGS inside it)…

PAGE-CODE- A :

//Page-A ---> EVENTOS (here your Login is located!)
import wixStorage from 'wix-storage';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
var storageDATA = {};

//------ User-Interface ---------------------------
var DATABASE = "Bypass-DB"
var onlineTime = 1 //in minutes!
//------ User-Interface ---------------------------

$w.onReady(()=> {setInterval(logOut, (onlineTime*1000*60));
    let data = wixStorage.session.getItem('storageDATA');
    if (typeof data === 'string') {console.log("Data in STORAGE found! ", storageDATA);
        storageDATA = JSON.parse(data); console.log("Parsed-Data: ", storageDATA);
    }
    else {console.log("No data in STORAGE found!"); create_storageDATA();}
     
  $w("#btnLogin").onClick(async()=> {console.log('Button clicked!'); console.log(storageDATA);
        if(storageDATA.onlineState === "true") {console.log("Online-Time not expired yet!");
            //What to do here ...........???????
            console.log("REDIRECTION TO WHAT PAGE EVER!")
            wixLocation.to("/page-b"); //--> redirection to page-B; User-Logged-in

        }
        else {console.log("Online-Time expired! Please log-in again!")
            let email = $w("#email").value;                 console.log("Entered-Email: ", email);
            let password = $w("#password").value;           console.log("Entered-Password: ", password);
            let dbDATA = await checkLogin(email, password); console.log("DB-RESULTS: ", dbDATA);

            if (dbDATA.length > 0) {//setting online-status...
                storageDATA.onlineState = "true"
                storageDATA.maxLoginTime = onlineTime;
                storageDATA.element = "button2";
                storageDATA.command = "hide";
                wixStorage.session.setItem("storageDATA", JSON.stringify(storageDATA));
                wixLocation.to("/page-b"); // --> redirection to page-B (principal); User-Logged-in
            } else {console.error("Email/password wrong!");
                //wixWindow.openLightbox('loginwarn');
                storageDATA.onlineState = "false"
                wixStorage.session.setItem("storageDATA", JSON.stringify(storageDATA));
            }
        }
    });

    $w("#btnLogout").onClick(async()=> {logOut();});
});

function create_storageDATA() {console.log("Creating new Storage-Data running...");
    storageDATA =  {
        onlineState: "false",
        maxLoginTime: onlineTime,
        element: undefined,
        command: undefined,
    }
}

async function checkLogin(email, password) {
  return wixData.query(DATABASE)
  //.eq("title", email)
  .eq("email", email)
  .eq("password", password)
  .find().then((res)=>{return (res.items);});
}

function logOut() {
    console.log("Your ONLINE-TIME has been expired! Logout-Process running!"); 
    storageDATA.onlineState="false"; 
    wixStorage.session.setItem("storageDATA",  JSON.stringify(storageDATA));
}

PAGE-CODE-B:

import wixStorage from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function () {
    let storageDATA = JSON.parse(wixStorage.session.getItem("storageDATA")); console.log(storageDATA);
    console.log("Command: ", storageDATA.command);
    console.log("Element: ", storageDATA.element);
  
    //command in action --> hiding the wished element on your page-B
    $w(`#${storageDATA.element}`)[storageDATA.command]()
    // wixLocation.to("/plogin")
});

EXAMPLE:

https://russian-dima.wixsite.com/login-system/page-a

So you have now a working EXAMPLE you can compare with your own solution.

And now! After all these somekind of rude sounding words → HAVE FUN & GOOD LUCK WITH YOUR PROJECT! :wink:
I hope you have learned → That CODING can be a very TIME-CONSUMING thing!

BTW: Do not forget to change all ELEMENT-IDS to your own ones!