Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can php cron jobs access session variables/cookies?

Tags:

php

cron

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!

like image 744
kregg Avatar asked Nov 09 '09 06:11

kregg


People also ask

Can PHP session work with browser cookies?

Sessions in PHP normally do use cookies to function. But, PHP sessions can also work without cookies in case cookies are disabled or rejected by the browser that the PHP server is trying to communicate with.

What does Cron PHP do?

A cron job in PHP powered systems, in particular, is often used to ensure timely execution of important tasks including executing or scheduling a code snippet. They are often used for system maintenance.

How cron jobs are triggered?

The tick cycle in cron is to repeatedly sleep for a minute, or less if there is a job coming up. Immediately after emerging from the sleep, it checks the time and treats the result as one of these wakeupKind values: Expected time - run any jobs we were expecting.


1 Answers

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().

like image 147
deceze Avatar answered Oct 27 '22 01:10

deceze