473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with unique session variables

Hi,

I got here the following problem. I am programming
web application for examing students.
After student will log on I need to keep his ID,
Privileges, Login, Password for manipulating with other
functions. All these information I will keep by

Session["ID"] = "2"
Session["Privileges"] = "Student"

and so on...
But my problem is, when later will log on teacher in
Session["Privileges"] will be "Teacher". It will be
replaced, so student will receive privileges of teacher.
And that is my problem. I heard that it is neccessary to
create unique ID for session.
I am working in ASP.NET with C# and there is
possibility to create this ID with method
Session.SessionID() but I dont know how to use it, how
those session variables can be different...

Is anybody here, who can show me some easy example how
to solve my problem?
Please. Thank you very much...

Newton

Nov 17 '05 #1
5 4451
Newton,

Session variables are unique by nature.

Unless the teacher and the student log on to the exact same machine (and for
that matter without closing the browser windows) the Session["Privileges"]
variables will be tracked seperately for each user.

You shouldn't have a problem using the Session variable as is.

I hope this is good news! :)

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Newton" <ne***********@pobox.sk> wrote in message
news:03****************************@phx.gbl...
Hi,

I got here the following problem. I am programming
web application for examing students.
After student will log on I need to keep his ID,
Privileges, Login, Password for manipulating with other
functions. All these information I will keep by

Session["ID"] = "2"
Session["Privileges"] = "Student"

and so on...
But my problem is, when later will log on teacher in
Session["Privileges"] will be "Teacher". It will be
replaced, so student will receive privileges of teacher.
And that is my problem. I heard that it is neccessary to
create unique ID for session.
I am working in ASP.NET with C# and there is
possibility to create this ID with method
Session.SessionID() but I dont know how to use it, how
those session variables can be different...

Is anybody here, who can show me some easy example how
to solve my problem?
Please. Thank you very much...

Newton

Nov 17 '05 #2
-----Original Message-----
Hi,

I got here the following problem. I am programming
web application for examing students.
After student will log on I need to keep his ID,
Privileges, Login, Password for manipulating with other
functions. All these information I will keep by

Session["ID"] = "2"
Session["Privileges"] = "Student"

and so on...
But my problem is, when later will log on teacher in
Session["Privileges"] will be "Teacher". It will be
replaced, so student will receive privileges of teacher.
And that is my problem. I heard that it is neccessary to
create unique ID for session.
I am working in ASP.NET with C# and there is
possibility to create this ID with method
Session.SessionID() but I dont know how to use it, how
those session variables can be different...

Is anybody here, who can show me some easy example how
to solve my problem?
Please. Thank you very much...

Newton

.

..Net will create the unique ID automatically.

In machine.config, set the

<sessionState mode=

setting to "InProc" (unless you have a web farm, then
you'll need to use a StateServer or SQLServer to maintain
session state). Also set the appropriate session timeout
(in minutes) in the same line. This will timeout the
session within the set number of minutes of INACTIVITY.

Then provide the user with a way to logout, which should
call Session.Abandon to log out of the current session.

Finally, at the top of each page, check Session
["Privileges"], and if not set, redirect to the login page.

That should allow you timeout users, and allow them to log
themselves out.

Bill Richardson
Proflowers.com
Nov 17 '05 #3
Hi,
believe me... they are not unique by nature... I started
internet explorer with my application and logged on as a
student, clicked the button and this application shown me
that student has logged on. Then i opened another
explorer and logged on as a teacher, clicked the button
and application shown me that teacher has logged on. Then
I returned to that explorer where student has logged on,
clicked the button and it shown me, that teacher has
logged on, so the session variable was overwritten.

Believe me... theyu are not unique by nature...
-----Original Message-----
Newton,

Session variables are unique by nature.

Unless the teacher and the student log on to the exact same machine (and forthat matter without closing the browser windows) the Session["Privileges"]variables will be tracked seperately for each user.

You shouldn't have a problem using the Session variable as is.
I hope this is good news! :)

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


Nov 17 '05 #4
Newton,

Was this on the same machine? Sessions are unique to the machine not to each
browser window...

If this was on the same machine then you are getting the behaviour this was
designed to produce.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Newton" <ne***********@pobox.sk> wrote in message
news:08****************************@phx.gbl...
Hi,
believe me... they are not unique by nature... I started
internet explorer with my application and logged on as a
student, clicked the button and this application shown me
that student has logged on. Then i opened another
explorer and logged on as a teacher, clicked the button
and application shown me that teacher has logged on. Then
I returned to that explorer where student has logged on,
clicked the button and it shown me, that teacher has
logged on, so the session variable was overwritten.

Believe me... theyu are not unique by nature...
-----Original Message-----
Newton,

Session variables are unique by nature.

Unless the teacher and the student log on to the exact

same machine (and for
that matter without closing the browser windows) the

Session["Privileges"]
variables will be tracked seperately for each user.

You shouldn't have a problem using the Session variable

as is.

I hope this is good news! :)

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

Nov 17 '05 #5
Justin,

I was just facing a similar problem. But I have 2 machines. One one machine everything works fine i.e session variable is not overwritten but in other case, the value gets overwritten.

So what could be the reason for this? :confused:

Newton,

Was this on the same machine? Sessions are unique to the machine not to each
browser window...

If this was on the same machine then you are getting the behaviour this was
designed to produce.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Newton" <newton.finsko@pobox.sk> wrote in message
news:082401c350ef$17ff29b0$a601280a@phx.gbl...[color=blue]
> Hi,
> believe me... they are not unique by nature... I started
> internet explorer with my application and logged on as a
> student, clicked the button and this application shown me
> that student has logged on. Then i opened another
> explorer and logged on as a teacher, clicked the button
> and application shown me that teacher has logged on. Then
> I returned to that explorer where student has logged on,
> clicked the button and it shown me, that teacher has
> logged on, so the session variable was overwritten.
>
> Believe me... theyu are not unique by nature...
>[color=green]
> >-----Original Message-----
> >Newton,
> >
> >Session variables are unique by nature.
> >
> >Unless the teacher and the student log on to the exact[/color]
> same machine (and for[color=green]
> >that matter without closing the browser windows) the[/color]
> Session["Privileges"][color=green]
> >variables will be tracked seperately for each user.
> >
> >You shouldn't have a problem using the Session variable[/color]
> as is.[color=green]
> >
> >I hope this is good news! :)
> >
> >--
> >S. Justin Gengo, MCP
> >Web Developer
> >
> >Free code library at:
> >www.aboutfortunate.com
> >
> >"Out of chaos comes order."
> > Nietzche[/color]
>[/color]
Jul 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: M.D. | last post by:
Hi, I am having a problem with my program which only happens when using Mozilla or Firefox. The pages I wrote, are part of a private web directory, a service offered by the ISP, which upon...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
3
by: Newbie | last post by:
I am using a Datagrid to show the contents of a DataTable. But it seems like the Datagrid is not getting the contents of the Datatable when the button ( btnAddAnotherLaborCategory) is clicked. ...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
6
by: Patrice Scribe | last post by:
I noticed that the SessionID is now a complex string instead of a simple number as it was under ASP. I believe it could be because when session variables are persisted ot the database, reusing a...
3
by: Philip Tepedino | last post by:
I'm having an odd problem. My website's session state is getting shared between users! This problem only happens when a user tries to access the site from inside our corporate LAN. The user,...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
2
by: fizbang | last post by:
This should be impossible, but for some reason, people are not getting individual sessions. They start a session. I set the session("application") variable to the unique number generated by an...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.