可以php cron作业访问会话变量/ cookie? [英] can php cron jobs access session variables/cookies?

查看:98
本文介绍了可以php cron作业访问会话变量/ cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的cron工作,我已经做了很多关于这个主题的搜索,但我不能完全理解。

解决方案

cron作业将无法访问cookie,因为根据定义,它不会从Web浏览器请求中调用。只有Web浏览器存储一个包含会话ID的cookie。没有网络浏览器,没有cookie,没有会话。



不过,如果你不知道会话ID,你应该能够手动启动会话,方法是将ID添加到 session_id()

i am new to cron jobs and i have done much searching on this topic but i couldn't understand it fully. can cron jobs access cookies or session variables?

thanks!

解决方案

A cron job won't be able to access cookies, since by definition it is not being invoked from a web browser request. Only the web browser stores a cookie, which contains the session id. No web browser, no cookie, no session.

Having said that, if you do know the session id somehow, you should be able to start the session manually by feeding the id into session_id() before using session_start().

这篇关于可以php cron作业访问会话变量/ cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆