Urgent plz.

liunx

Guest
urgent plz.

I want to ask you friends how to use session by VB in the asp.net pages

actually I used by C# like

String valid = (String) Session["admin"];
if(valid!=null){
Response.Redirect("admin.aspx");

but may we do it by VB

I'm waitning your relpy

thanksI believe implicit typecast is fine in VB so you could do
if (Session("admin") is not Nothing)
'code here

But I use C# so I'm not too familiar with VB syntax.thanks

but it doesn't workSession in VB.Net:

if Session.Item("Admin") is nothing then
' put whatever code you need here
end if


if Session("Admin") is nothing then
' put whatever code you need here
end if

should work too.

If you want to cast the session variable later, you can use:

CType(Session.Item("Admin"), String) to cast it to a string, or whatever it might be.

Good Luck!

Happy New Year!You can just treat a session variable as a string and use the len function. If
If len(session("userid")) = 0 thenthanks

it works now

but how can i use the session timeout and what are its benifitssessions expire after 20 minutes (not really but they are supposed to be default). The trouble is the asp.net session is not reliable, infact session end events do not even fire right as a session ends, they fire after the session but not immediatly. I would actually suggest against using the session for anything where you need the time to be precise. I would use a cookie. Plus you can really make a cookie last for as long as you want, its a good way to store a login.
 
Back
Top