Writing cookies isn’t really the correct way, but using some variety of browser storage isn’t a bad way to go. (It’s the tool that we have.)
Yeah, if you need something to persist across not just the current session but also across different devices, the only way to do that is via the database.
But one doesn’t always need the second part. If one just wants to preserve some data across browser sessions (or simply within the current session), use some form of browser storage. (SHAMELESS PLUG: Floppy)
But to the OP’s question:
Any data held in memory in a page (e.g., in a custom state or a custom state-like thing like a plugin element’s outputs) goes away across page loads.
So, you can pass the value to another page via the querystring (i.e., “send data to a page”, which is a pretty terrible misnomer), or you can write it to browser storage (using a non-crappy storage plugin like [SHAMELESS PLUG] Floppy).
(Floppy supports all three varieties of universally-supported browser storage - session, local, and IndexedDB - depending upon what you need/desire to do.)
Granted, @firstfifteensoftware, Bubble’s lack of support for objects beyond Things makes database storage attractive (for Things), but there are many cases where one would desire to store some bits of data without having to keep passing them along from page to page via querystring parameters (which won’t survive the session anyway) or by generating cruft in one’s database and having to manage removal of it once done.