How to save a viewer specific option

Is there a standard interface in WordPress for saving a global PHP
variable $bgcolor to the user and read it from him anytime he browses
to another blog page.

There is nothing that will automagically do it for you but it sounds like you just need to save a little bit of user meta, and of course retrieve it.

Since you asked about saving the variable, I am going to assume that the custom sidebar widget that switches the background color already works. Just add code, based on the two Codex entries above, that checks the user meta and saves changes.

If you post your code, I may be able to give a more elaborate answer.

If you are talking about generic visitors, and not WordPress users, setting a cookie is your best choice. There are no built in generic “cookie setter” functions that I am aware of. WordPress itself uses PHP’s setcookie in a fair few places, for example in wp_set_auth_cookie, and I don’t know why that function would need a “helper”. It is fairly straighforward.