If you are using Laravel then edit your session.php and set
domain' => ".domain.dev" // the domain.dev and all subdomains
Register a CORS Middleware since Laravel 5 it could look like
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
public function handle($request, Closure $next)
{
if ($request->is('api/*')) {
return $next($request)
->header('Access-Control-Allow-Origin', 'http://subdomain.domain.dev')
->header('Access-Control-Allow-Credentials', 'true')
->header('Access-Control-Allow-Methods', 'GET, POST');
}
return $next($request);
}
}
if you using vue reseouce you need to set:
Vue.http.options.credentials = true;
With jquery the request should look like:
$.ajax({
type : "GET",
url : 'http://domain.dev/api/users',
async: false,
xhrFields: {
withCredentials: true
},
success : function(data, textStatus, xmLHttpRequest){
console.log(data);
}
});