public class Cls_Vars_RC {
private const string UserIdKey = "SID";
private static HttpSessionState Session {
get {
return HttpContext.Current.Session;
}
}
public static bool Exists {
get {
return !(Session == null);
}
}
public static string UserId {
get {
return Session(UserIdKey);
// Return
}
set {
Session(UserIdKey) = value;
}
}
public void CriaSessao(string ID) {
Current.Session("SLogin") = true;
Current.Session("SID") = ID;
}
public void ApagaSessao() {
Current.Session("SLogin") = false;
Current.Session("SID") = "";
}
bool CHKSession() {
if ((Current.Session("SLogin") == true)) {
return true;
}
else {
return false;
}
}
}
VB.NET
Public Class Cls_Vars_RC
Private Const UserIdKey As String = "SID"
Public Sub CriaSessao(ByVal ID As String)
Current.Session("SLogin") = True
Current.Session("SID") = ID
End Sub
Public Sub ApagaSessao()
Current.Session("SLogin") = false
Current.Session("SID") = ""
End Sub
Function CHKSession() As Boolean
If Current.Session("SLogin") = True Then
Return True
Else
Return False
End If
End Function
Private Shared ReadOnly Property Session() As HttpSessionState
Get
Return HttpContext.Current.Session
End Get
End Property
Public Shared ReadOnly Property Exists() As Boolean
Get
Return Not Session Is Nothing
End Get
End Property
Public Shared Property UserId() As String
Get
Return Session(UserIdKey)
' Return
End Get
Set(ByVal value As String)
Session(UserIdKey) = value
End Set
End Property
End Class
Sem comentários:
Enviar um comentário