Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Interview question

How do you use cookies with different domains and paths? अलग-अलग domains और paths के साथ cookies?

Answer
setcookie('admin_token', $token, [
    'path' => '/admin',
    'secure' => true,
    'httponly' => true
]);
setcookie('user_id', $id, [
    'domain' => '.example.com',
    'secure' => true
]);
PropertyPurpose
pathOnly send for requests to this path
domainRestrict to domain and subdomains
setcookie('admin_token', $token, [
    'path' => '/admin',
    'secure' => true
]);
setcookie('user_id', $id, [
    'domain' => '.example.com',
    'secure' => true
]);
Propertyउद्देश्य
pathसिर्फ इस path के लिए
domainDomain तक सीमित करना

Was this answer clear?