现在我正在使用ngCookies
,我需要知道如何实现它以及如何在用户注销时销毁该数据
我设置此功能以检索数据
$scope.localStorageInfo = function() {
$scope.userDisplayInfoName = $cookieStore.get('username');
$scope.userDisplayInfoEmail = $cookieStore.get('email');
};
$scope.localStorageInfo();
$scope.signIn = function () {
$scope.userDisplayInfoName = $rootScope.name.displayName;
$scope.userDisplayInfoEmail = $rootScope.name.email;
$cookieStore.put('username', $rootScope.name.displayName);
$cookieStore.put('email', $rootScope.name.email);
};
那么,这是正确的方法吗?以及如何在用户注销时销毁该数据,以及如何从localStorage中删除该数据?
答案 0 :(得分:2)
<asp:GridView ID="grvstdRes" runat="server" CssClass="table table-bordered table-hover" OnRowCommand="grvstdRes_RowCommand" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Document">
<ItemTemplate>
<asp:LinkButton ID="lnkstdres" runat="server" Text='<%#Eval("Alias") %>'
CommandArgument='<%#Eval("Idinstance") %>' CommandName="StudentResAliasName" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void grvstdRes_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="StudentResAliasName")
{
using(objResultUnitBLL=new UnitBLL())
{
using(objUnitDTO=new UnitDTO())
{
objUnitDTO = objResultUnitBLL.GetStudentResourceFile(Convert.ToInt64(e.CommandArgument));
string fileName=objUnitDTO.FileName; //to get the full path from DB
string[] pathArr = fileName.Split('\\'); // To split the path
fileName = pathArr.Last().ToString(); //To get the file name with extension
Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('../Upload/Instance/" + fileName + "','_newtab');", true); //to display the file in new window.
}
}
}
}
答案 1 :(得分:1)
remove
方法破坏你的cookie:
$cookieStore.remove('username');