To get username or login name using SSOM is very simple

    string strUserName = SPContext.Current.Web.CurrentUser.LoginName;

To get username from CSOM

    function getCurrentUser() {  
       context = new SP.ClientContext.get_current();  
        web = context.get_web();  
      currentUser = web.get_currentUser();  
      context.load(currentUser);  
      context.executeQueryAsync(onSuccessMethod, onRequestFail);  
    }  

You can use this query string to pass username to another URL.Make sure it is encrypted before passing  in url