Hi,
Im trying to access a session variable in a user control but its not working :( Can anyone help?? I think I need another 'Import .....' bit but im not sure which one as ive tried everything I thought would make it work and nothing...
Here's the code:
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web
Imports System.Xml
Namespace Cienet
Public Class Security
Public Sub New()
End Sub
' Declare property variables
Private _intIdAgency as Integer
Private _intIdUsername as Integer
Private _intPagePermissionId as Integer
' Declare class variables
Private _strPermissions() as String
Private _strCmdReturn as String
Public WriteOnly Property AgencyId as Integer
Set (ByVal intIdAgency as Integer)
_intIdAgency = intIdAgency
End Set
End Property
Public WriteOnly Property UserId as Integer
Set (ByVal intIdUsername as Integer)
_intIdUsername = intIdUsername
End Set
End Property
Public WriteOnly Property PagePermissionId as Integer
Set (ByVal intPagePermissionId as Integer)
_intPagePermissionId = intPagePermissionId
End Set
End Property
Public Function SessionPermissionsCheck()
If Session("PermissionsString").ToString() = "" Then
Dim objSqlConnection as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))
Dim objSqlCommand as New SqlCommand("spPagePermissions_Check", objSqlConnection)
objSqlCommand.CommandType = CommandType.StoredProcedure
objSqlCommand.Parameters.Add("@idAgency", SqlDbType.Int, 4).Value = _intIdAgency
objSqlCommand.Parameters.Add("@idUsername", SqlDbType.Int, 4).Value = _intIdUsername
objSqlConnection.Open()
_strCmdReturn = objSqlCommand.ExecuteScalar()
objSqlConnection.Close()
Session("PermissionsString") = _strCmdReturn
End If
_strPermissions = Session("PermissionsString").Split(",")
If Convert.ToInt32(_strPermissions(_intPagePermissionId)) = 1 Then
Return True
Else
Return False
End If
End Function
Public Function LivePermissionsCheck()
Dim objSqlConnection as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))
Dim objSqlCommand as New SqlCommand("spPagePermissions_Check", objSqlConnection)
objSqlCommand.CommandType = CommandType.StoredProcedure
objSqlCommand.Parameters.Add("@idAgency", SqlDbType.Int, 4).Value = _intIdAgency
objSqlCommand.Parameters.Add("@idUsername", SqlDbType.Int, 4).Value = _intIdUsername
objSqlConnection.Open()
_strCmdReturn = objSqlCommand.ExecuteScalar()
objSqlConnection.Close()
_strPermissions = _strCmdReturn.Split(",")
If Convert.ToInt32(_strPermissions(_intPagePermissionId)) = 1 Then
Return True
Else
Return False
End If
End Function
End Class
End Namespace