Ask coding questions

← Back to all posts
Can you change a server side variable through client side? Node.js
AAnonymity (1)

Can you change a server side variable through client side?

Node.js

I have been searching for how to do this in Google and Stack Overflow for many days, but I still do not have a clear answer. The title says it all. I appreciate all the effort!

Commentshotnewtop
mwilki7 (518)

I'm not sure how, at first glance, how to change server variables but the first thing I would try is build some sort of interface to change the server:
example:

client:

function changeServerDate(date)
{
    // send date over socket to server
}

server:

var serverdate;
socketthingy.on("changeDate", function(date)
{
    serverdate = date;
});
AAnonymity (1)

@mwilki7 : Oh, so I need to use socket.io. Well, I am not that familiar with that. Do you know any good resources to learn socket.io?

mwilki7 (518)

@AAnonymity Here's a skeleton for a simple chat room that I found online
https://repl.it/@mwilki7/NodeJS-Chatroom

JustARatherRidi (191)

Sure you can, but it depends on what sort of server you've got running and what data you're looking to send. Could you perhaps share a link to your code?