Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Script at domain A fontend/views codeigniter:

<script>
    $(document).ready(function($) { 
        $.ajax({
            type: "POST",
            url: "http://domainB/setcookie.php",
            data:{
                'id': 'value'
            },
            success: function(data){
                console.log(data);
            }
        });
    });
</script>

And http://domainB/setcookie.php file:
<?php

 setcookie("u_id", $_POST["id"], 0, '/');

?>


And run http://domainB/index.php file:

The result of $_COOKIE["u_id"] is NULL EMPTY. I want $_COOKIE["u_id"] is "value".


What I have tried:

try domain A active domain B setcookie self
Posted
Comments
Patrice T 21-Jun-17 23:16pm    
And you have a question or a problem ?
Vinh Tran 22-Jun-17 0:12am    
I want $_COOKIE["u_id"] is "value"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900