Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,
I am working with a website, in which the users can search for topics present in the database.Now i want to show the users, the last 5 searches done by the user on log out.How can i implement that...
Thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 17-Aug-12 1:11am    
First of all, not clear how it could be "on log out". If a user logged out already, this person is nobody, should not have rights to look at any personal data.

And if this is shown per the user's account, which can make sense, what's the problem? Do you have database? You should have some data per user, so what's the problem to show some of it on a page?
--SA
AmitGajjar 17-Aug-12 1:21am    
what you have do so far?
virang_21 17-Aug-12 1:27am    
If you want to persist data keep it in database table with user name and search term. If you need it just for that interaction period store it in session and on logout display what is in session
sandeep nagabhairava 17-Aug-12 1:35am    
i think cookies may help you ;)
ridoy 17-Aug-12 1:51am    
Do your want search query for last 5 or full implementation code?

Cookies are the easiest way.
Each time teh do a search, retrieve the existing cookie, remove the oldest if there are five already, and add teh new serach to teh cookies list. Then save that back.
MSDN: How to write a cookie[^]
 
Share this answer
 
we can using profiling for this purpose.Its found to be the simplest and most optimum way to solve implement this function.
 
Share this answer
 
What you need to do is to persist the last 5 searches.

To persist data you can use
1. cookie (client side)
2. session (server side)
3. storing to database

Among the above 3 options, I would prefer storing data in cookie provided the search string length is not so big.

You can create a string with a delimiter, some thing like this
search 1;search 2;search 3.....
and store the string in cookie.

While getting the string, read the cookie and show it wherever you want it to show.

Hope this helps.
cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900