Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

store data for bookmarklet

Tags:

bookmarklet

I am making a bookmarklet, which calls a Google App Engine app. The GAE app uses login information, which I want to store in bookmarklet, so when user first clicks bookmarklet,it asks for login info, but from next time onwards it automatically supplies it.

like image 380
vishesh Avatar asked Mar 12 '12 18:03

vishesh


People also ask

How does the bookmarklet work?

The bookmarklet is executing like code in the developer tools console, and bypasses the configured Content Security Policy (CSP). The "Hello, World!" link can just as easily send data to another server, including the input of form fields, or cookies.

What is the PDF download bookmarklet?

The PDF Download bookmarklet allows you to convert the current webpage to a PDF file. It works in any web browser, including Firefox, Chrome, Opera, Internet Explorer, and Opera. If you own a Kindle, you can easily send articles on webpages straight to your Kindle for later reading.

How do I save a bookmarklet?

Use the Save button to save the bookmarklet right where you clicked. Tip: There are several situations where a bookmarklet might come in handy, so having a single folder on the bookmarks bar where you store all of them is a great idea.

What is the readability bookmarklet and how do I use it?

The Readability bookmarklet also allows you to clean up a webpage for cleaner viewing. They have bookmarklets that allow you to clean up the page for current viewing, for reading later (requires registration), and for sending to your Kindle.


1 Answers

The difficulty of a bookmarklet directly storing data is that it can only store data in cookie or in localStore, both of which "belong" to whatever page it is currently on. That means it won't work again the next time you use it on a different page, and it also means the page you are on can access the data, which is generally very bad for security.

There are two basic ways your situation is generally handled. The two main ways are:

1.) The application used keeps the user logged in with a cookie. The login information is not stored in the cookie; only a session ID is. This is like when you return to many popular websites, you don't have to log in again. Very often these types of bookmarklets open a small popup for the user which contains a page from the app. If the user is not logged in, the app prompts the user to login first. The bookmarklet in fact knows nothing about being signed in or not.

2.) Each bookmarklet is custom created for each person. So my bookmarklet would be different than yours. The difference is simply that mine will contain my login info in the code, and yours will contain your login information in the code. In fact we would each have to login to the app first before we can get our own personalized bookmarklet.

Generally, option 1 is better and easier and more secure.

like image 129
DG. Avatar answered Oct 03 '22 15:10

DG.