Answered by:
copying URL

Question
-
User-1578974752 posted
How can I make a session value disappear upon copying the url to another browser. Thanks
Wednesday, May 22, 2019 8:58 AM
Answers
-
User753101303 posted
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 ?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 28, 2019 8:24 AM -
User665608656 posted
Hi shsu,
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.
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 28, 2019 9:49 AM
All replies
-
User753101303 posted
Hi,
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 ?
Wednesday, May 22, 2019 9:58 AM -
User-1578974752 posted
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.ExecuteNonQuery()
cmd.CommandText = "SELECT TOP(1) UserTestID FROM UserMaster ORDER BY 1 DESC"
drd = cmd.ExecuteReader
If drd.HasRows = True Then
drd.Read()
UserTestID.Text = drd.Item("UserTestID")
Kattempt.Text = drd.Item("AtteptID")
End IfThanks.
Thursday, May 23, 2019 3:05 AM -
User665608656 posted
Hi shsu,
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.
Best Regards,
YongQing.
Thursday, May 23, 2019 10:06 AM -
User753101303 posted
Hi,
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.
Thursday, May 23, 2019 11:06 AM -
User-1578974752 posted
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.If Not IsPostBack Then
Dim record = Session("record")
If record Is Nothing Then
Session("record") = "have started"
Else
Response.Write("you have started the exam")
'Response.End()
Session.Remove("record")
Response.Redirect("Login.aspx")
End If
End If
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
Tuesday, May 28, 2019 5:07 AM -
User753101303 posted
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 ?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 28, 2019 8:24 AM -
User665608656 posted
Hi shsu,
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.
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 28, 2019 9:49 AM -
User-1578974752 posted
Thanks to all for solving my issue
Friday, May 31, 2019 3:20 AM -
User-1578974752 posted
Hi All
If I need to show as message box in JavaScript when it reaches 5 minutes? Thanks
Monday, June 3, 2019 12:58 AM