Make changes to current user, without him being registered?

Is it possible to store data on a user who just arrived on the website?

If yes, how?

I have tried: On page load --> Make changes to current user (I’m adding this URL to a custom field). But when I visit the user table, I don’t see this URL inside my custom field.

Unregistered users are saved as cookies. The changed data is visible as soon as the user registers and a user data entry is created in the DB, which automatically gets the saved changes from the cookie.

1 Like

@reger-alexander thanks for this information!

Is there a way in Bubble to “save” information on a logged out user, even if he closes his browser?

[…] If the user is logged out, you can still modify the user object, but once the user closes their browser, you will not be able to access the user’s information.

Or I must use custom javascript to create my own cookie for this purpose?

I guess you could track a user’s IP, There is no solid way to track logged out users as they are protected by privacy laws.

You can store cookies.

Legally, I can store cookie as long as the user accepts it.

The question is can I do it with Bubble, or I must do it with Javascript?

    // Helpers 
    function setCookie(cname, cvalue, exdays) {
		var date = new Date();
		date.setTime(date.getTime() + (exdays*24*60*60*1000));
		var expires = "expires="+ date.toUTCString();
		document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
	}

	function getCookie(cname) {
		var name = cname + "=";
		var decodedCookie = decodeURIComponent(document.cookie);
		var ca = decodedCookie.split(';');
		for(var i = 0; i <ca.length; i++) {
			var c = ca[i];
			while (c.charAt(0) == ' ') {
			  c = c.substring(1);
			}
			if (c.indexOf(name) == 0) {
			  return c.substring(name.length, c.length);
			}
		}
		return "";
	}

You can use this plugin

1 Like

Thanks @reger-alexander, I assume that It’s not possible with bubble and that I must use JS or a Plugin, I’ll use Javascript here (it was a matter of 2 minutes development.) But I’m surprised that bubble won’t let you store custom cookies.

You can use the JavaScript Workflow plugin for this. I think bubble already tracks people. So its possible to store current user even when they are logged out.

@nocodeventure Thanks, I bought it.

Technically how is that plugin able to execute server-side Javascript ?
Even if it requires lots of code, how can I execute server-side JS without a plugin?

I couldn’t find this information inside the reference: https://bubble.io/reference. But for anyone searching, I found it on the forum, it’s possible to execute some server-side Javascript by creating a plugin.

Create a new plugin: https://bubble.io/my_plugins, then click on:
Actions --> Add a new action --> General properties --> Action type [Server side]

tags: bubble nodejs node server-side javascript js