设置Cookie不会保存

时间:2019-02-11 20:16:01

标签: php cookies

我已经设置了POSTMAN来测试外部API,并且它按照以下方式设置Cooke:

visa=319134-355996-1-1549389451--eyJhbGciOiJSUzI1NiIsImtpZCI6IjlDRkRFRDg0NDhEMzcwM0NCNTQ5QjhCRTU2N0JCMDkyNTMxOEZDMUQiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJuUDN0aEVqVGNEeTFTYmktVm51d2tsTVlfQjAifQ.eyJuYmYiOjE1NDkzODk0NTEsImV4cCI6MTU0OTM5MzA1MSwiaXNzIjoiaHR0cHM6Ly9zc28ubmF2aWdhdG9ybG9naW4uY29tIiwiYXVkIjoiaHR0cHM6Ly9zc28ubmF2aWdhdG9ybG9naW4uY29tL3Jlc291cmNlcyIsImNsaWVudF9pZCI6IjM5ZDljOWU5LTRjOWYtNGY0Mi05ZGNkLTYxZmE3YmM4NTNmNyIsInN1YiI6Ijk4MzdiZjg0LTU3MzEtNGY0Yi04ZjQzLWE3MzE5MDkwYmFhNiIsImF1dGhfdGltZSI6MTU0OTM4OTQ1MSwiaWRwIjoibG9jYWwiLCJzY29wZSI6WyJlbWFpbCIsIm9wZW5pZCIsInByb2ZpbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.cBW6nbXvMZCwg!hiuPlks2bXhu!RQxwpzDBvl!!1QhmYxyeDoBGidDSXu89YxsxVlpkvAYbq6mgEaOlZFwuieOM_Z7KZqOJXHrtP460xc21eyau1DSyJalW9nkEO6DjxemRO2o3P4q10iIpupbmsd39TkcaBGhe9mHnqSqH8fveaTExGDimnBchqfswPYX2yUZSN1HbzadiPpKL5LAU9t!kQuLmV_LvuNr2QoqmZW!03RYpv648GGvAueLkr2VGVRkkJT!upfIWJ6cJbeLrdfY315xp88ZTkC9p5uNl6GnJwQEBGSSbtpjIEd6Pc339zHGpMyz4cVc2vNJfEpT1R1g-654b43210dcc68d962ecdcea1e06e767f742a360765a915b78670ca64eb91713-4AAB7A1E3261EB00CF799B573E23A5949C8BA4C42BCCA72D698DBAD1D5C6D8EC-307C7C7C7C317C556E646566696E6564; path=/; domain=.backup.management; Secure; HttpOnly; Expires=Tue, 19 Jan 2038 03:14:07 GMT;

我正在尝试在PHP中实现此功能,因此我尝试像这样设置Cookie:

setcookie ( 'visa', $login["visa"], time()+3600, '/', 'backup.management', 1, 1);

(其中$login["visa"]是长字符串)

但是,当我尝试使用echo $_COOKIE["visa"];回显cookie时,它告诉我它无效。

在PHP中设置cookie时我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

以简单的方式尝试SET

setcookie("TestCookie", $value, time()+3600); 

GET

echo $_COOKIE["TestCookie"];