Store multiple values in a session variable
- by user458790
Hi,
Before I ask my doubt, please consider this scenario that a user on my website have a profileID. With this profileID are associated some pluginID's. For eg: User1 might have 2, 3 and 5 plugins associated with its profile.
When the user logs in, I store the profileID of the user in a session variable cod. At a certain page, the user tries to edit the plugins associated with his profile. So, on that page, I have retrieve those pluginID's from the DB.
I have applied this code but this fetches only the maximum pluginID from the DB and not all the pluginID's.
SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where id=(select id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]) + ")", con);
SqlDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
while (dr1.Read())
{
Session["edp1"] = Convert.ToInt32(dr1[0]);
}
}
dr1.Close();
cmd1.Dispose();
I was trying to figure out how can I store multiple pluginID's in this session variable?
Thanks