Thank you Patrik ! But how I do this when I click on EXIT ? something like this: I know that i may use href="#" to redirect to another page, is that right ? But how I end the session as well and get back to the login page ? Thanks
yes dear if you want to do anything at server side(like end session here) then you have to do like that..because using only <li><a></a></li> will not end your session, it will jst take you to the other page.
Pratik Galoria,
Software Engineer,
iGATE Global Solutions.
yes dear if you want to do anything at server side(like end session here) then you have to do like that..because using only <li><a></a></li> will not end your session, it will jst take you to the other page.
Got it ! Thanks a lot !
Just one more thing, what If in the <li><a></a></li> I redirect to the log in page and in the Page_Load of login.aspx i used
that is the same thing too..but understand one risk..If anyone click on logout/exit link and suddenly he/she closes the browser before even your login.aspx page opens, what will be the result?? he/she will remain logged in..so better thing would be, first
end the session and then redirect..otherwise both are the same thing.
Pratik Galoria,
Software Engineer,
iGATE Global Solutions.
that is the same thing too..but understand one risk..If anyone click on logout/exit link and suddenly he/she closes the browser before even your login.aspx page opens, what will be the result?? he/she will remain logged in..so better thing would be, first
end the session and then redirect..otherwise both are the same thing.
True.. You're right Thanks again Patrik, for keeping helping me xD . Gee, im so noob ;s
One more thing and i'll stop bothering you, I promese !
I just need a little 'push' to get start and i can do the rest on my own. I'm getting a little difficult to start thsi sessions thing
-I have my log in page, I make a SELECT in the DataBase to see if the login/password match. I Know that if its right I have to begin the session.
Session["Login"] = TxtLogin.ToString();
But what then ? I don't know what to do next... Other thing is, if I type the path for a page, it gets in the page normally, without needing login.. Could you help me to fix it ? Or just show me the way. I'm not lazy, I'm searching in google a lot, but nothing
worked so far. And I need this to my job, im at it right know =P
Ghaleon
Member
22 Points
89 Posts
Session and New WIndow
Dec 12, 2012 11:29 AM|LINK
Hi Everyone !
I used to programm in WindowsForms C# but now I have to learn Web programming (Asp.Net with C# ) SO here I am, trying . . .
I'd like to know how I create a "Session" for LOG in ?
And I have a <li> EXIT </li> how I end the session and go back to the log in page when I click on it ?
Thanks ~'
pratik_galor...
Participant
1483 Points
330 Posts
Re: Session and New WIndow
Dec 12, 2012 11:33 AM|LINK
to create Session:
Session["User"] = "user1";
to retrieve session:
string user = (string)Session["User"];
to end session:
Session.Abandon();
Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
geniusvishal
Star
13984 Points
2783 Posts
Re: Session and New WIndow
Dec 12, 2012 11:45 AM|LINK
Refer:
http://rameshtalla.wordpress.com/2012/01/30/login-page-and-logout-page-code-using-cookies-and-sessions/
http://www.codeproject.com/Questions/219891/Login-and-logout-System-using-session
My Website
www.dotnetvishal.com
Ghaleon
Member
22 Points
89 Posts
Re: Session and New WIndow
Dec 12, 2012 11:54 AM|LINK
Thank you Patrik ! But how I do this when I click on EXIT ? something like this: I know that i may use href="#" to redirect to another page, is that right ? But how I end the session as well and get back to the login page ? Thanks
pratik_galor...
Participant
1483 Points
330 Posts
Re: Session and New WIndow
Dec 12, 2012 12:35 PM|LINK
yes you can do that this way,
<li><asp:LinkButton OnClick="lnkExit_Click" runat="Server" Text="Exit"></asp:LinkButton></li>
and in aspx.cs write this code,
protected void lnkExit_Click(object sender, EventArgs e) { Session.Abandon(); Response.Redirect("Login.aspx"); }Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
Ghaleon
Member
22 Points
89 Posts
Re: Session and New WIndow
Dec 12, 2012 12:45 PM|LINK
So I HAVE TO add a button on my <li></li> ? Because I was using just the link of <li> like this:
<ul class="leftnav"> <li><a href="#">Usuários</a> <ul class="submenu"> <li><a href="/CadastraUsuario.aspx">Cadastrar Usuário</a></li> <li><a href="#">Alterar Usuário</a></li> <li><a href="#">Apagar Usuário</a></li> </ul> </li> <li><a href="#">Minhas Tarefas</a> <ul class="submenu"> <li><a href="#">Chamados</a></li> <li><a href="#">Chamados em Aberto</a></li> <li><a href="#">Finalizados</a></li> </ul> </li> <li><a href="#">Clubes/Projetos</a> <ul class="submenu"> <li><a href="#">Inserir Clube</a></li> <li><a href="#">Alterar Clube</a></li> <li><a href="#">Apagar Clube</a></li> </ul> </li> <li><a href="#">Chamados</a> <ul class="submenu"> <li><a href="#">Cadastrar Novo Chamado</a></li> <li><a href="#">Manipular</a></li> <li><a href="#">Atividades</a></li> </ul> </li>pratik_galor...
Participant
1483 Points
330 Posts
Re: Session and New WIndow
Dec 12, 2012 01:01 PM|LINK
yes dear if you want to do anything at server side(like end session here) then you have to do like that..because using only <li><a></a></li> will not end your session, it will jst take you to the other page.
Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
Ghaleon
Member
22 Points
89 Posts
Re: Session and New WIndow
Dec 12, 2012 03:16 PM|LINK
Got it ! Thanks a lot !
Just one more thing, what If in the <li><a></a></li> I redirect to the log in page and in the Page_Load of login.aspx i used
protected void Page_Load( . .. { Session.RemoveAll(); }Would it work ?
pratik_galor...
Participant
1483 Points
330 Posts
Re: Session and New WIndow
Dec 12, 2012 03:24 PM|LINK
that is the same thing too..but understand one risk..If anyone click on logout/exit link and suddenly he/she closes the browser before even your login.aspx page opens, what will be the result?? he/she will remain logged in..so better thing would be, first end the session and then redirect..otherwise both are the same thing.
Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
Ghaleon
Member
22 Points
89 Posts
Re: Session and New WIndow
Dec 12, 2012 03:50 PM|LINK
True.. You're right Thanks again Patrik, for keeping helping me xD . Gee, im so noob ;s
One more thing and i'll stop bothering you, I promese !
I just need a little 'push' to get start and i can do the rest on my own. I'm getting a little difficult to start thsi sessions thing
-I have my log in page, I make a SELECT in the DataBase to see if the login/password match. I Know that if its right I have to begin the session.
But what then ? I don't know what to do next... Other thing is, if I type the path for a page, it gets in the page normally, without needing login.. Could you help me to fix it ? Or just show me the way. I'm not lazy, I'm searching in google a lot, but nothing worked so far. And I need this to my job, im at it right know =P
Thanks again Patrik ! You're a great guy !