I am developing a web application. Actually what my requirement is, as a user logs in the application, and as he/ she logout, within the time period I need to generate a unique number which, I need to save in my database for that user. (i 'll do
some other things with this number along with user)
and if the same user logins in again in the application it should be different, i.e for every user and for every login it should be unique. Although I have a primary key in my database table. i need to save this also with uniquness.
let me know how to do the logic. It should be done in many ways, I need the best way...
Thanks
It is our choices that show what we truly are, far more than our abilities...
demoninside9
Participant
1260 Points
1721 Posts
value should remain same for a particular session
Mar 02, 2012 03:21 AM|LINK
Hi all,
I am developing a web application. Actually what my requirement is, as a user logs in the application, and as he/ she logout, within the time period I need to generate a unique number which, I need to save in my database for that user. (i 'll do some other things with this number along with user)
and if the same user logins in again in the application it should be different, i.e for every user and for every login it should be unique. Although I have a primary key in my database table. i need to save this also with uniquness.
let me know how to do the logic. It should be done in many ways, I need the best way...
Thanks
koogamagnum
Member
97 Points
35 Posts
Re: value should remain same for a particular session
Mar 02, 2012 03:52 AM|LINK
Have you thought about using a GUID? http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx That will be unique everytime.
me_ritz
Star
9337 Points
1447 Posts
Re: value should remain same for a particular session
Mar 02, 2012 03:54 AM|LINK
Hi Gaurav,
Everytime someone opens a browser, it generates a unique sessionid for each browser session.
You can get that in c# like:
Session.SessionID for unique browser session
demoninside9
Participant
1260 Points
1721 Posts
Re: value should remain same for a particular session
Mar 02, 2012 04:12 AM|LINK
its aslways same if we go from one form to another...? or page postbaks ?
me_ritz
Star
9337 Points
1447 Posts
Re: value should remain same for a particular session
Mar 02, 2012 04:17 AM|LINK
Yes...always same...if you go from one page to another ....or postbacks occurs...
it doesn't change until you close the browser...or restart
demoninside9
Participant
1260 Points
1721 Posts
Re: value should remain same for a particular session
Mar 02, 2012 04:19 AM|LINK
http://chiragrdarji.wordpress.com/2007/07/28/sessionsessionid-is-not-unique/ but here the picture is different
me_ritz
Star
9337 Points
1447 Posts
Re: value should remain same for a particular session
Mar 02, 2012 04:34 AM|LINK
Well...what can i say is...you test it....and see how it behaves....and let me know.
I have implemented this in past with success.
demoninside9
Participant
1260 Points
1721 Posts
Re: value should remain same for a particular session
Mar 02, 2012 05:53 AM|LINK
yes I tested it
I did lblNumber.Text = this.Session.SessionID;
and for every postback it changes the value. I tested for 3 postbacks and the values are
rowaonfqbubhox452x4zequc
jrci2n45vwewkd45jqiffnz0
hy12nx555bneopulauqlgw55
which are different.
Thanks
me_ritz
Star
9337 Points
1447 Posts
Re: value should remain same for a particular session
Mar 02, 2012 07:59 AM|LINK
Finally came up with a link....that suits your requirement....making sessionid unique for a browser session...
Read it carefully...
http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid.aspx
maniindia06
Member
4 Points
2 Posts
Re: value should remain same for a particular session
Mar 02, 2012 09:59 AM|LINK
Yes you are correct