• Post Reply Bookmark Topic Watch Topic
  • New Topic

Distinguish first time from second time call  RSS feed

 
sudheshna Iyer
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I know whether a particular request is a first time request or second
time request. I need to implement some logic only for the second time request.

Also I want to know how many times a request has come from the same user. I
need to ask the user to login after certain number of usages to the site.

Your help is greately appreciated.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a good job for cookies.
Check for the cookie, if it's there than you know they've been to your site before.

One of the values in that cookie could be an integer that gets incremented with each hit to the site.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sudheshna aaa",
your display name is not valid according to the Javaranch display name rules.

Please see the request to change it here.

thanks,
Dave.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sudheshna",

Your display name is now even less compliant than before. Take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

bear
Forum Bartender
 
sudheshna Iyer
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
andra kan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Incase cookies are disabled can we use the getsession functionality to
check if the request is a first time request or not.

request.getsession(false) will return a session object if one exists already.

For a first time request, this would be null and from this we can identify
a first time request.

( create a new session if null)

For subsequent requests, this wont be null..

I hope this will work.
Thanks ,
Andra
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Utilizing a session would only work up to the point of a session timeout. It could not, for exammple, determine if the user had visited the day before.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!