main site : perfectwp.com/index.php Code
<font size="5">Hello this is my main site</font><br/>
<font size="5">to visit my secondry site <a href="http://perfectwp.site" target="_blank">click here</font></a>
secondary site : perfectwp.site/index.php code
<?php
if(!isset($_SERVER['HTTP_REFERER'])){
// redirect them to your desired location
header('location:404.php');
exit; } ?>
<font size="5">Hi Welcome to my Secondry site you are coming from my main site
<br/><br/><br/>watch video below</font> <br/><br/><br/>
<iframe width="560" height="315" src="https://www.youtube.com/embed/-i0OIy5zSrs" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
if visitor is redirecting through main site he gets secondary site content but if user is trying to access secondary site directly returns 404. and this is working now.
The question is if user is redirecting from main site how we can set cookies or session for him. or how we can tell browser do not check this restriction for this user on next visit
[i request to admin please do not hide my question i really really need help]