Home > Mobile >  How to get cookie in php send from Node.js application
How to get cookie in php send from Node.js application

Time:11-18

How to get cookie in php send from Node.js application? I am not fimiliar to php. How to get this cookie creted in nodejs in php?

    const express = require('express')
    const app = express()
    const port = 3000
    
    app.get('/', (req, res) => {
    
        res.setHeader("Set-Cookie","type-test");
        res.setHeader("Year",new Date().getFullYear);
      res.send('Hello World!')
    })
    
    app.listen(port, () => {
      console.log(`Example app listening at http://localhost:${port}`)
    })

CodePudding user response:

Example -

<?php
$cookie_name = "type-test";

if(!isset($_COOKIE[$cookie_name])) {
  echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
  echo "Cookie '" . $cookie_name . "' is set!<br>";
  echo "Value is: " . $_COOKIE[$cookie_name];
}
?>
  • Related