Home > Net >  Asp.net how to use the Session between multiple pages by value to each other
Asp.net how to use the Session between multiple pages by value to each other

Time:04-20

In asp.net, designed a login page, a page and a page message board, want after logging in the user name to login to the home page and message boards on the Label of the navigation bar and click on the front page after page of Label still displays the current logged in user, which is as long as no matter how to switch after the login page can ensure the Label shows the current logged in user,

CodePudding user response:

Direct assignment, again is not good,,,
The Session (" UserName ")="123456";


If (Session (" UserName ")!=null)
{
Label. The Text=Session (" UserName "). The ToString ();
}

CodePudding user response:

refer to the original poster weixin_45132257 response:
in asp.net, designed a login page, a page and a page message board, want after logging in the user name to login to the home page and message boards on the Label of the navigation bar and click on the front page after page of Label still displays the current logged in user, which is as long as no matter how to switch after the login page can ensure the Label shows the current logged in user,


Session expiration problem is very serious, it is suggested that use cookie authentication, set an expiration time line, the session on a single server when a line still, if across servers, your session configuration is more trouble
  • Related