-
Jun 28th, 2010, 11:56 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] SessionID question
Hello Everybody,
I have an ASP.NET page that has a wizard control. I need to see if the same user is working on the page so I first time I insert a record and next time I update database records. I am using Session.SessionID to check if the same user is working on the page, but on every postback, SessionID gives a unique string and always the "insert" construct executes.
What is the best way to check the same user is working back and forth on the same page. User is not logged in, its an open form on the page.
Thanks.
-
Jun 28th, 2010, 12:11 PM
#2
Frenzied Member
Re: SessionID question
hay,
i hardly can understand what you mean can you clear things more?
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:17 PM
#3
Re: SessionID question
usamaalam,
I think you are going to need to show some of the code that you are using?
Gary
-
Jun 28th, 2010, 12:20 PM
#4
Thread Starter
Frenzied Member
Re: SessionID question
Yes sure.
I have a page where there is a form. The form is in 12 steps. The user fills in the first step and click Next, on the click of Next button I "insert" the data in the database. On step 2, the user fills in the form and this time I need to "update" the database record that was previously entered in the step 1. Similarly, user may click back button and go again on step 1, change the data and click Next. This time again record should be "updated".
In my database table, I added one field called "SessionID". When first time I insert record, I also insert Session.SessionID in this field. Next time I check if Session.SessionID = SessionID (in database) I update the record. But Session.SessionID always gives me a new value.
I need a value that should remain the same for that user throughout his working on the page.
Thanks.
-
Jun 28th, 2010, 12:25 PM
#5
Re: SessionID question
What sort of information are you inserting into this table? Do you have any concept of user membership? If so, I think the Profile Provider might be able to provide you with what you need.
The technique that you are using though is definitely valid, so I am curious to see the code that you are using to see where it could be going wrong.
Gary
-
Jun 28th, 2010, 12:25 PM
#6
Frenzied Member
Re: SessionID question
hay,
actually why you doing all of this,
from your first step, you successfully inserted your row, which mean you have your primary key for this row, you can store this value in your session,
and update your row according to your row in the next step using the stored value for the primary key in your session.
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:28 PM
#7
Re: SessionID question
Originally Posted by avrail
hay,
actually why you doing all of this,
from your first step, you successfully inserted your row, which mean you have your primary key for this row, you can store this value in your session,
and update your row according to your row in the next step using the stored value for the primary key in your session.
The point that he is making is that the SessionID, which is his primary key, is changing, even though it is the same user.
The only reason this should happen is if the application pool gets recycled, or if the session expires.
Gary
-
Jun 28th, 2010, 12:31 PM
#8
Thread Starter
Frenzied Member
Re: SessionID question
The problem is just resolved. Session.SessionID was not persistent but when I saved something in a session variable, it works great. I added the following line on my page load event and now I get same value of Session.SessionID on every postback.
Code:
Session["Test"] = "Test";
Do you want me to put the rest of the code here?
Thanks a lot.
-
Jun 28th, 2010, 12:33 PM
#9
Frenzied Member
Re: SessionID question
Originally Posted by gep13
The point that he is making is that the SessionID, which is his primary key, is changing, even though it is the same user.
The only reason this should happen is if the application pool gets recycled, or if the session expires.
Gary
sure if the session ID changed, and the user are the same, then his session id must be expires,
but he didn't actually said that he using the SessionID as a primary key ?? did you usamaalam?
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:33 PM
#10
Re: SessionID question
Hey,
This is definitely the way to go.
Either create a Session object for each "thing" you need to remember, or create a class that represents everything that you need, and put this into a Session variable.
I am still surprised that Session.SessionID is giving different results though?!?!
If you have got it working, then no need to upload the rest of your code.
Gary
-
Jun 28th, 2010, 12:36 PM
#11
Frenzied Member
Re: SessionID question
hay usamaalam,
please are you using the SessionID as a Primary key for your table ?
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:37 PM
#12
Thread Starter
Frenzied Member
Re: SessionID question
I was surprised too, I took a simple plane page and put the following line in page load and was getting a new value on every refresh.
Code:
string sessionID = Session.SessionID;
Thanks avrail and gep13 for all your help.
-
Jun 28th, 2010, 12:39 PM
#13
Thread Starter
Frenzied Member
Re: SessionID question
Originally Posted by avrail
hay usamaalam,
please are you using the SessionID as a Primary key for your table ?
Yes I am using SessionID as candidate key.
-
Jun 28th, 2010, 12:41 PM
#14
Frenzied Member
Re: SessionID question
amm, so please gep correct me if i was wrong,
is there any possibility this SessionID be the same after sometime, let us say month??
actually i don't know the mechanism that session id created by.
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:41 PM
#15
Re: SessionID question
On a side note, you might want to take a look at the following:
http://msdn.microsoft.com/en-us/libr...ewsession.aspx
Gary
-
Jun 28th, 2010, 12:43 PM
#16
Re: SessionID question
Originally Posted by avrail
amm, so please gep correct me if i was wrong,
is there any possibility this SessionID be the same after sometime, let us say month??
actually i don't know the mechanism that session id created by.
That really comes down to how Session is configured on the server. It is possible to extend the Session timeout, but for a time period of a month, you would be looking to persist that information somewhere else, not in Session.
Gary
-
Jun 28th, 2010, 12:48 PM
#17
Frenzied Member
Re: [RESOLVED] SessionID question
no, you misunderstand me
primary key is Unique,
what if your sessionID inserted into the database as a primary key, and after a month someone else used the page, and he has a new SeesionID, can we grantee this new SessionID not used before ???
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 12:50 PM
#18
Thread Starter
Frenzied Member
Re: [RESOLVED] SessionID question
Originally Posted by avrail
no, you misunderstand me
primary key is Unique,
what if your sessionID inserted into the database as a primary key, and after a month someone else used the page, and he has a new SeesionID, can we grantee this new SessionID not used before ???
Actually in my case, I just need to save the data, perform very little calculation, email the result and the data is then useless and will never be fetched. This is why I don't care if SessionID is repeated, since I am comparing SessionID plus Today's date.
Thanks.
-
Jun 28th, 2010, 12:53 PM
#19
Frenzied Member
Re: [RESOLVED] SessionID question
that's good for you
but i still care, is it a sessionId unique for ever or for some reason it will be repeated ?
i love this Q
any way it is not a big deal
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011
-
Jun 28th, 2010, 01:28 PM
#20
Re: [RESOLVED] SessionID question
If I had to guess, I would say that this is something to do with the use of the ASP.Net Development Server. I would be curious to know if this happened on a web application under IIS.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|