我想開發記住用戶下次在windows phone 7應用程序中登錄用戶憑據的功能(如網站上的「記住我」功能)請告訴我如何爲此請在Windows手機7在Windows Phone 7應用程序中的cookie管理
感謝
我想開發記住用戶下次在windows phone 7應用程序中登錄用戶憑據的功能(如網站上的「記住我」功能)請告訴我如何爲此請在Windows手機7在Windows Phone 7應用程序中的cookie管理
感謝
可以存儲在手機的獨立存儲的憑據。任何其他應用程序都無法訪問您的應用程序的隔離存儲。最簡單的方法是這樣的:
public void SaveCredentials()
{
var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("username", "user123");
settings.Add("password", Encrypt("password123");
}
然後你可以檢索爲:
string username = settings["username"].ToString();
string password = Decrypt(settings["password"].ToString());
你可以寫這取決於你的安全需求的加密/解密方法。有許多方法具有不同級別的安全性和複雜性。爲了幫助你開始,可以找到這樣一種方式HERE。
上面的答案有幾個更新。
爲了節省:
private void SaveCredentials()
{
IsolatedStorageSettings.ApplicationSettings.Add("username", username);
IsolatedStorageSettings.ApplicationSettings.Add("password", password.ToString());
}
要檢索:
string username = IsolatedStorageSettings.ApplicationSettings["username"];
string password = IsolatedStorageSettings.ApplicationSettings["password"];