Cognitive radio (CR) and integrated sensing and communication (ISAC) are both critical technologies for the sixth generation (6G) wireless networks. However, their interplay has yet to be explored. To obtain the mutual benefits between CR and ISAC, we focus on a reconfigurable intelligent surface (RIS)-enhanced cognitive ISAC system and explore using the additional degrees-of-freedom brought by the RIS to improve the performance of the cognitive ISAC system. Specifically, we formulate an optimization problem of maximizing the signal-to-noise-plus-interference ratios (SINRs) of the mobile sensors (MSs) while ensuring the requirements of the spectrum sensing (SS) and the secondary transmissions by jointly designing the SS time, the secondary base station (SBS) beamforming, and the RIS beamforming. The formulated non-convex problem can be solved by the proposed block coordinate descent (BCD) algorithm based on the Dinkelbach's transform and the successive convex approximation (SCA) methods. Simulation results demonstrate that the proposed scheme exhibits good convergence performance and can effectively reduce the position error bounds (PEBs) of the MSs, thereby improving the radio environment map (REM) accuracy of CR networks. Additionally, we reveal the impact of RIS deployment locations on the performance of cognitive ISAC systems.