How to save and fetch user search history on web apl - javascript

am working on a navigation web app. And I want to save user search history and display them on the search page. Can I do that without the user logged in.

Apart from cookies that #Alex mentioned, there is something called localStorage in javascript that enables you to store some data on the computer of your user. These would be the most convenient way to implement search history without involving any login or server-side stuff.

Related

Persistent login data after refreshing page in React

I have created a login page in React which takes user data and opens a User Page with the user's name. When I refresh this page again, it loses user data. I am storing user data in redux store.
If I want to make it persistent what should I do? Should I use local storage or create a Mysql DB to store data? Which one is better for a large application?
It looks like a backend job to me ...
Your persistence should probably be on the express side of your application.
If you really want to do it with React only check this :
https://www.npmjs.com/package/redux-react-session
There are a lot of resources on the Web about sessions :
https://auth0.com/blog/adding-authentication-to-your-react-flux-app/
https://code.tutsplus.com/tutorials/data-persistence-and-sessions-with-react--cms-25180
...

Where to store user data in SPA

I have been developing a SPA with AngularJS and I have stored the user data in an Angular Value service but I do not feel confortable with that, basically because the Angular Value is not shared between browser tabs. So if the user opens a new browser tab and on every page refresh (F5) I have to request the server the user data like full name, email, etc. I am using a REST API.
Is this approach fine or not?. If I use localStorage it will help me to share data between tabs but I do not know if it is a better technique.
There are only 3 places you could store your data in a browser
Cookie
Local storage
Database (IndexedDB or Web SQL)
You can open your console panel to see these option.
Consideration:
Security
It depends on how important or sensitive your data stored in the
browser, if it is user sensitive, you should never stored them in the browser in the 1st place!
Size
how big is the data, you going to store? if it is huge it is good to store them in the Database, you could check out some of this framework (PouchDB)
if it is small, you could just store them in the local storage

Saving app state in jQuery mobile

I have done a bit of research on how to do this but can't find any.I have an app that has a Home page.On this homepage, there is a Register button.I want to implement a system where if the user clicks on this and registers, the app never starts with the Register button displayed again,but rather, a view Profile button.How do i implement such a system? My guess is to store some boolean value in localstorage, and check this value when the app starts?
Update: I just thought i'd add that my jquery mobile app communicates with a Google App Engine (Python) web service which already uses Google's User's Service
I believe you are looking for Local Storage Jquery Mobile.
You have to store data when user click on Register button, and every time when app will open it checks is there is any data in Local Storage. Then you can use your logic.
You can also use HTML5 Local Storage with Jquery Mobile. But some device browser dose not support Local storage if you want to check this you should go for Modernizer.
This is simple code of checking local storage using modernizer:
if (Modernizr.localstorage) {
// Supported
}
else {
// Not Supported
}
If you only store a boolean after the user is logged-in, yes you know that a user is logged in but you don't know which one.
Te best approach is to store the user's token which you will send as a parameter in all requests so that you can validate them.
When entering the website if there is a token you must validate it by querying the server. If it's not valid then you show the register/login page. If the token is valid you could login the user automatically.
Whatever plugin you decide to use be sure to check that if it is a localStorage plugin it also has fallback for cookies. (Maybe some clients will have browsers that don't support localStorage)
On this page there are 3 functions that I personally use when I need access to cookies.
Here you have some details about token authentication.
I would advise you to store the token using cookies.
This answer describes one of the best ways of managing user sessions based on tokens.

How to pass a custom parameter to facebook login?

I have a static website without any server side languages.
Is it possible to pass some custom values whenever a user tries to login then get the data back when the user successfully signed in and comes back to my website from facebook?
I've read about signed_request, but that requires PHP.
You're essentially asking if Facebook will store data for you.
Unfortunately, the answer is no. You need some kind of mechanism on your server that can match a Facebook user to the data you need stored.
You could use local storage, but that's obviously local to the browser and prone to tampering.

Facebook Apps and Cookies

Do facebook applications written with the help of FBJS need access to cookies? Say for example, my application just gets the the friends of logged in user into an array.
Do facebook applications written with
the help of FBJS need access to
cookies? Say for example, my
application just gets the the friends
of logged in user into an array.
You don't need cookies there. You can store whatever you want into the session (for temporary storage) or use a database instead. The logical move will be to store users into database in most cases.

Categories

Resources