no_one
October 17, 2020, 2:33pm
1
So in my website, i have made a js array for comments: https://freezing-honeysuckle-quill.glitch.me/
But the problem is, after i leave a comment, reload the page, they’re gone!
How can i program a script to save the comments? Can i do that with cookies?
It is advisable to use a persistent database, especially for something like a comment system.
Cookies and localStorage store data that is only visible to a particular browser, and they’re not visible to other users, which is is not something you would want for a comment system. Because in a comment system, you should be able to see comments by everyone and not just yourself (unless you want some self-motivation ). Also, cookies and localStorage can get cleared when you clear your browser cache. Therefore I conclude, cookies and localStorage are not suitable places to store data.
2 Likes
If you are looking for a good database, I would have to recommend MySQL. Its easy to learn.
1 Like
Of course, that is debatable. So I’m not going to say which is better than which but rather, I’m gonna say which all are good databases.
MySQL
MongoDB
SQLite (works best for Glitch)
Redis
Postgres
If it’s your first time using databases, you can use adapters like https://endb.js.org or https://quickdb.js.org .
There are usernames and passwords involved for most of these databases, so it’s essential that you have a backend/server. Recommended: Node.js.
I’m not saying PHP is bad for databases, but Node.js has more support for databases these days and more secure. Again, it’s your choice.
1 Like
Read the spoiler text, please.
1 Like
Read the spoiler text, please.
1 Like
Ok, let’s not turn this into a battle between who’s better: Node.js vs PHP.
Your choice. Use the one you feel comfortable with.
1 Like
no_one
October 17, 2020, 5:06pm
10
Let’s not use this format it’s annoying
Anyways, can i do that on STATIC websites?
there’s no way you will be able to view user submitted content, unless you send the data to somewhere everyone can access. If you want to keep your site static just rely on a external service or create a comment box that stores in somewhere decenteralized like ipfs
no_one
October 17, 2020, 5:37pm
12
Uhm, can i do that with cookies?
document.cookie = "Comment1=Nice Website!; expires=Thu, 18 Dec 9999 12:00:00 UTC";
document.cookie = "Comment2=Woooow!; expires=Thu, 18 Dec 9999 12:00:00 UTC";
document.cookie = "Comment3=How did you do that?!?!; expires=Thu, 18 Dec 9999 12:00:00 UTC";
@no_one you can use third-party comment services on your static site with a minimum of fuss.
<div class="commentbox"></div>
<script src="https://unpkg.com/commentbox.io/dist/commentBox.min.js"></script>
<script>
commentBox('my-project-id')
</script>
Before you begin, please create a project in the CommentBox.io Dashboard . Click here to learn more about the dashboard and how to use it.
1 Like
no_one
October 17, 2020, 5:45pm
14
I just feel like it’s wrong, and that still doesn’t answer my original question.
I wanna make it with javascript arrays!
Well, there are limitations with what you can make with only JS arrays.
1 Like
no_one
October 17, 2020, 5:52pm
18
Good point, but i actually wanna make a system of commenting, not a comment system.
no_one
October 17, 2020, 5:54pm
20
you tell me.
Listen, how does this work: https://heymessage.glitch.me/
I wanna know so badly
(even tough i made it)
no_one
October 17, 2020, 5:56pm
21
No, it’s not socketio, i made it with js
My dear @no_one , that is NOT a static website. That is a dynamic page, it uses Node.js.
no_one:
you tell me.
I asked you and now you’re asking me. How wonderful.
Are you sure you made it?
1 Like
no_one
October 17, 2020, 5:59pm
23
yes, i made it, but most of the code is just the default glitch express dream list thingy.
It is not. It is using an SQLite database. And it’s clearly written in the README.
2 Likes
no_one
October 17, 2020, 6:00pm
25
listen, i just added css and a button. k?
It is just a remix of the default glitch dream list project
That’s the ~hello-sqlite project.
I’ll make it more clear for you.
It uses SQLite which is a database system to store all the stuff.
1 Like
no_one
October 17, 2020, 6:04pm
27
apparently i get the same dream list with express.
Express is a routing framework. Not a database.
1 Like
no_one
October 17, 2020, 6:05pm
29
But i get the same thing, try it!
Which project? ~hello-express?
no_one
October 17, 2020, 6:11pm
33
oh, ok. I’ll find other methods
1 Like
You could try the hello-commento starter that I made.
commento on Glitch!
Commento is one of the best comment system for websites, blogs, etc. And I found out it runs perfectly on Glitch. Steps:
Learn how to get a free postgreSQL database here . DO NOT VISIT YOUR APP YET.
Remix the project here! . Make the project private.
Change “start.sh.example” to “start.sh”
In start.sh, change POSTGRES_URI=postgres://user:pass@hostname:5432/dbname to the URI that Heroku gave you from step 1.
In start.sh, change PROJECT_URL to teh url of your project (e.g. htt…
It’s a simple comment system.
3 Likes
no_one
October 17, 2020, 6:13pm
35
Thanks for the suggestion!
Oh, i need to pay… no thanks!
no_one
October 17, 2020, 6:15pm
39
why does it say “30-day trial”?
no_one
October 17, 2020, 6:18pm
41
i cannot really pay for a domain, i need to embed it.
Uhm, you can just use the .glitch.me domain. I did that for a few days until Glitch activated my custom domain (comments.aboutdavid.me )
1 Like
no_one
October 17, 2020, 6:25pm
44
Uhm, in the comments it says that i’ve got an incorrect password/email, but when i log in to the dashboard it logs me in succesfully, you should fix that!
I didn’t make commento, I just make the Glitch starter kit.
Your best bet is just to learn sql:
3 Likes
well you’re going to need some way to get those arrrays from one computer to another. they don’t just appear on every computer like a scratch global variable
you can save them into cookies with JSON.stringify but a user would only be able to see their own comments.
1 Like
no_one
October 18, 2020, 4:50pm
50
That’s cool, i could make a notes page where you save your notes
You would only have 4kb of storage for that
browser, cookies
2 Likes
@khalby786 does indexed databases clear along with cookies?
It’s also worth noting if some one where to clear their browsing history that the cookies will be deleted. It’s like fresh cookies being thrown out the window. But it’s a lot worse.
smart humans can uncheck the clear cookies and browsing data when clearing their history lol.
Let me test that indexeddb thing
So, I just checked in the “clear cookies” button and the indexedDB example i was looking at was cleared. So I guess it does…
2 Likes
system
Closed
April 17, 2021, 8:16am
56
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.