Last post Jun 03, 2019 12:58 AM by shsu
May 22, 2019 08:58 AM|shsu|LINK
How can I make a session value disappear upon copying the url to another browser. Thanks
May 22, 2019 09:58 AM|PatriceSc|LINK
Unclear. If not using a cookieless session the other browser session shouldn't be able to access to the other session.
If you are using cookieless browser sessions, you could keep track of Request.UserAgent in its own session variable and force a new session if you detect a change. In Global.asax you could add a check for this for each request (a least ASPX pages or you
are using MVC ?)
Make sure this kind of addition does bring some real benefit. Knowing what you are trying to prevent when a user does that could perhaps help to raise better suggestion ?
May 23, 2019 03:05 AM|shsu|LINK
I am using vb.net web forms. Using sessions. This session time out is 20 min.
Real scenario is like this.
Once I click start button , Insertion is happening in to the database with attemp 0. (Attempt is increasing to 1 only If the user login and come through the correct form.)
if the user copy the link,then also the Start button is visible for them in new browser.
Once they click start,again insertion is happening in to the database with attempt 0 again.Can give idea on how to prevent insertion when they copy link and click start button.
cmd.CommandText = "Insert into UserMaster(AtteptID,QuestionMasterID,EmailID,TestDatetaken)values ('" + attemp.Text + "','" + qusetid.Text + "','" + Useremail.Text + "','" + Ctime.Text + "')"
cmd.CommandText = "SELECT TOP(1) UserTestID FROM UserMaster ORDER BY 1 DESC"
drd = cmd.ExecuteReader
If drd.HasRows = True Then
UserTestID.Text = drd.Item("UserTestID")
Kattempt.Text = drd.Item("AtteptID")
May 23, 2019 10:06 AM|Yongqing Yu|LINK
According to your description, I can not understand your question clearly.
Do you want to click on the start button after the user logs in successfully,then click once, add a piece of data to attemp (starting from 0),when the user replicates the link to another window and clicks the button again, the system needs to identify the
number of data added, rather than adding from 0 again?
If my description is correct, could you please tell me that when you click the start button, is the added data (attempt 0, 1, 2, 3...) stored in the database?
If I misunderstand, I hope you could describe your needs in more detail, which will help us solve this issue more easierly.
May 23, 2019 11:06 AM|PatriceSc|LINK
Seems you could just check the database content rather than keeping in memory something that is supposed to tell what happened previously. Else you'll have anyway the same problem if the user closes the browser and relaunch it it would start a new session
and you'll lose what happened previously.
Loading maybe this in memory "on demand" would be just a possible optimization but your "source of truth" should be what is stored in the database.
Not directly related but have a look for ADO.NET parameters. You should avoid to build a full SQL string yourself.
May 28, 2019 05:07 AM|shsu|LINK
Now I am preventing the Insert into DB ,if they copy the link.
Prevented copying link by putting below code. It is redirecting to login page.
Dim record = Session("record")
Response.Write("you have started the exam")
But now my issue is I Cannot allow user to login for 20 min, if they answering the current Test.ie need to prevent concurrent session from login. How can I make it possible?
Appreciate the Help
May 28, 2019 08:24 AM|PatriceSc|LINK
With what you have done if the user is closing the browser and relaunch or is clearing cookies Session("record") will be nothing again. Not sure this is what you want.
Then it seems you want to keep the test start date/time so that you can prevent the user to keep entering answer once the test duration is over ?
May 28, 2019 09:49 AM|Yongqing Yu|LINK
According to your description, I can't understand your question clearly.
I wonder you want to prevent users from jumping to the login page once they enter the exam page, if the exam time exceeds 20 minutes, right?
If my guess is correct, you could give up using session,then record the time information of the user's first entry to the exam page to the database.
When the user requests the exam page, he can get the time information of the database record. If it already exists, he will jump to the login page.
If I guess wrong, please provide more detailed code, which will help us solve the issue easierly.
May 31, 2019 03:20 AM|shsu|LINK
Thanks to all for solving my issue
Jun 03, 2019 12:58 AM|shsu|LINK