You're doing the replace on the filename, not the contents. If it's a small file, you can use file_get_contents
and file_put_contents
instead.
$cookie_file_path=$path."/cookies/shipping-cookie".$unique;
$contents = file_get_contents($cookie_file_path);
file_put_contents($cookie_file_path, str_replace("12345", "77348", $contents));