How to get cookie by vue-electron

scenario: use electron to package vue applications.
attempt: an .html demo is established. The session of the main process can be obtained through node, and the cookie can be obtained

<script>
    var session = require("electron").remote.session;
    function getCookie(name) {
        session.defaultSession.cookies.get({ url: "http://www.github.com" }, function (error, cookies) {
            console.log(cookies);
        });
    }
</script>

problem: modules that use node in vue will not be obtained, resulting in not getting cookie

Apr.13,2022

electron applications have two processes, one browser and one node. Naturally, you cannot directly obtain the browser's cookie in node. You need to rely on the api provided by electron to communicate


refer to stack overflow , and you can introduce node module into index.html. Then use

in the .vue file
Menu