The js control pop-up box pops up only once when logging in.

how to control the pop-up box to pop up only once when the login is complete, turn it off and it won"t pop up again, and if you cut to another page, it won"t pop up. Will it pop up again the next time you log in?

clipboard.png

what I do now is pop up every time I cut to the front page, because I wrote such a piece of js code on the home page

<script type="text/javascript">
        $(document).ready(function () {
                var userId = $(".userId").attr("value");
// sessionStorage
                window.sessionStorage.setItem("userId", userId);
// sessionStorage
                var data = window.sessionStorage.getItem("userId");

                if (data != null) {
                    $.ajax({
                        //url: positionPath+"/position/app/cityinfo-add",
                        url: positionPath + "/position/app/checkinfo",
                        data: {"id": data},
                        dataType: "json",
                        type: "post",
                        success: function (jsonData) {
                            console.log(jsonData["data"]["checkinfo"]);
                            console.log(jsonData["msg"]);
                            console.log(jsonData["status"]);
                            if (1 == jsonData["data"]["checkinfo"]) {
                                $("-sharpregister_perfectInfo").show();
                            }
                        }
                    });
                }
                // sessionStorage
                window.sessionStorage.clear();

            }
        )
    </script>
Mar.04,2022

you can store the logged-in userId, or the logged-in token, in session, and then determine whether it exists on the home page, and pop up


if it doesn't exist.

first of all, your login status should be recorded when login is successful (cookie, localstorage, etc.)

The

code is added to determine whether the recorded state exists to control whether it pops up again

secondly, communicate with the backend to get the status
update the status of the record combined with the backend to verify whether the status of the record is valid, so as to control whether to log in and pop up again, so as to reach a point in time of cyclic
verification, which can be page reload (refresh), or the backend verifies whether the login status is valid each time the request is sent through token.

Menu