When using drupal_add_js with the 'setting' option, do the set variables apply for all users? I am trying to find out if the following function will just set the JavaScript variable for that specific user, or if it will switch back and forth between usernames.

function my_module_form_submit($form, &amp;$form_state) {
  $username = custom_get_username_function();
  drupal_add_js(array('user' =&gt; $username), 'setting');
}
Assuming that custom_get_username_function() returns a different username for each of the logged-in users, then that code will pass to JavaScript a different and a single username for each user. There could be 4 different logged-in user, but each user gets one username, assuming custom_get_username_function() is using the currently logged-in user ID to retrieve the username.

I would rather not add JavaScript code from a form submission handler; if I need to add it, I would add it to the form, or to the page where the users are redirected after they submit the form.