記住賬號密碼 (密碼賬號輸入框在設定的時間內有效)

2021-07-25 04:19:29 字數 890 閱讀 6658

前幾天在做記住賬號密碼這個功能,查了資料有了解到:cookie 與 session 兩種傳送 ,cookie是在客戶端保持登入狀態的機制;session是在服務端保持狀態的傳送。相同點就是可以保持視窗的登入狀態,不同點就是cookie容易被劫持,不安全,session相對而言更安全。了解到的就這麼多,現在就cookie來直接上**吧。       

html**有:

js**有: common.js

function $(objstr)

window.onload = function()

alert("登陸成功,歡迎你," + usernamevalue + "!");

self.location.replace("welcome.html");

}else alert("使用者名稱或密碼錯誤,請重新輸入!");

}}

cookie.js**:

//新建cookie。

//hours為空字串時,cookie的生存期至瀏覽器會話結束。hours為數字0時,建立的是乙個失效的cookie,這個cookie會覆蓋已經建立過的同名、同path的cookie(如果這個cookie存在)。

function setcookie(name,value,hours,path)

//獲取cookie值

function getcookievalue(name)

else return ""; //搜尋失敗,返回空字串

}//刪除cookie

function deletecookie(name,path)

git記住賬號密碼

涉及到記住密碼的方式,只適用於http s 方式,記住密碼的幾種方式 https 方式每次都要輸入密碼,按照如下設定即可輸入一次就不用再手輸入密碼的困擾而且又享受 https 帶來的極速 按照以下設定記住密碼十五分鐘 git config global credential.helper cache...

Git記住賬號密碼

git儲存使用者名稱密碼的方式 1 設定記住密碼 預設15分鐘 git config global credential.helper cache git config credential.helper cache2 如果想自己設定時間,可以這樣做 git config credential.he...

檢視git 賬號密碼和修改git賬號密碼

檢視使用者名稱 git config user.name 檢視密碼 git config user.password 檢視配置資訊 git config list 修改使用者名稱 git config global user.name x 新的使用者名稱 修改密碼git config global ...