Start sessions through command prompt

This post was written by Mahi-Bhat on January 1, 2013
Posted Under: PHP

Sessions are getting started using the PHPSESSID sent from the client browser through cookies. When you execute a php script from the command prompt, there is no browser to send or receive cookies.

But there is a way to read a session that someone with a browser has already accessed if you know their PHPSESSID cookie. Execute the following via command prompt, where ‘xxxxxxxx’ is user’s session ID.

/usr/bin/php -r ‘$_COOKIE[“PHPSESSID”] = “xxxxxxxx”;require_once(“sample.php”);’

Add a Comment

required, use real name
required, will not be published
optional, your blog address