Saving and checking Session ID

I was going through the tutorial section and been playing with bubble pretty much every day :slight_smile:

One of my question was: If I use the saving data tutorial, will the data be saved like “forever” somewhere on a database of bubble or will it just save data in a variable which will be cleared as soon as the page got closed?

Why am I asking this:
Step1: I want to save users “session ID” (I’ve found the variable within bubble) and I want to permanently save it somewhere (Also installed API connector but don’t know how to put it to use)!
Step2: I want my page, everytime it gets loaded, to check whether the current session ID of the user is saved in my database or not!

I don’t wanna use the login /signup feature at this point (in case someone asks).

What is the easiest way to do the above 2 steps?

Thanks once again :slight_smile:

Interesting idea - where did you find the session id?

You can save it to a permanent database and query the database field when someone visits your site to see if their session id matches. You just need to find the right condition on page load to check against the database = I’m not certain where that is.

Hey john, this is what I am planning. But I don’t know how to do it within bubble. How to insert data in a “permanent” database?

It should be pretty easy what data tables have you already created to make your app run? It seems to make most sense to me to add that to the user table. So just goto the user table and a field for session id.

You can then set a workflow to save this id this to the appropriate table. Most probably on page load.

I havent even created a database since I don’t really know how. I went through the “saving data tutorial” - is that what you meant with creating a database? I thought the video just shows how to create ( temporary) variables

Oh sorry!

Definitely do all the tutorials and watch all the videos as it will help you figure out how bubble works as you need a solid baseline understanding :slight_smile:

There is a learning curve to bubble so figure on spending at least 30-40 hours to get fully up to speed. It will be time well worth it in my opinion.

1 Like

Hey thanks, I went through them, still doesn’t really answers my question so I will ask again.

is the “saving data” tutorial the one that I need for “creating databases” or will it just create temporary variables that will get deleted after the page refreshes?

You should probably share a screenshot about what you’re talking about as I can’t understand.

I think this post answers the question, for a user not logged in:

2 Likes

THANKS! That is something that I can defnitely work with! But how can I access that said database?

(And how can I create one as well?)

Using the database for the bubble app, the same way as for stored data … in the editor choose Data, Data Types

Pick User, and

Then it is accessed as Current User’s SomethingUseful. Can save data into it either with autobinding to an input element, or in a workflow action doing "Make changes to User, SomethingUseful = Input’s value.

If the user is logged in, the value will get stored in the database. If the user is not logged in, it will behave as if it is stored, but is local to the browser, and disappear after being unused for 3 days. I haven’t tested the disappearing trick yet.

Looking again at your first post, I think what might suit better is saving the user’s IP address, and check if it exists in the database to see if you get a repeat visitor.

If you want to do this, add another plugin “ipiphy”. Create a new “Data Type” (effectively a database table), like VisitorInfo. In this data type, create a text field “IP address”. Then can have a workflow event “when page is loaded” and "search for VisitorInfo (constraint: IP address = Current User's IP address) :count = 0, then it can do the actions you want for new visitors.

Looking forward to see what you make!

3 Likes