The development of connected and automated vehicles (CAVs) is rapidly increasing in the next generation and the automotive industry is dedicated to enhancing the safety and efficiency of CAVs. A cooperative control strategy helps CAVs to collaborate and share information among the neighboring CAVs, improving efficiency, optimizing traffic flow, and enhancing safety. This research proposes a safe cooperative control framework for CAVs designed for highway merging applications. In the urban transportation system, highway merging scenarios are high-risk collision zone, and the CAVs on the main and merging lanes should collaborate to avoid potential accidents. In the proposed framework, the on-ramp CAVs merge at 40 mph within the same and opposite directions to the main lane CAVs. The proposed framework includes the consensus controller, safety filter, and quadratic programming (QP) optimization method. The consensus controller incorporates the communication between CAVs and designs the same consensus for all CAVs on both the main and merging lanes. However, when all CAVs try to achieve the same consensus, a potential collision might happen on the road. The safety filter is a crucial part of controller that requires the location, velocity, and safe distance information among CAVs to calculate the safe set for the controller. To balance both the consensus controller and the safety filter, QP is applied to have a safe, cooperative control input for all CAVs. The same and opposite merging scenarios are common in urban transportation systems, so we chose these two scenarios to validate the framework. In these scenarios, the cooperative control can avoid all the potential collision points and maintain the desired safe distance from neighboring CAVs. The simulation results demonstrate the effectiveness of the proposed safe cooperative control framework for complex highway merging scenarios considering safety criteria like time to collision (TTC), safety margin, headway time (HT), etc.