<i id='tNCmX'><tr id='tNCmX'><dt id='tNCmX'><q id='tNCmX'><span id='tNCmX'><b id='tNCmX'><form id='tNCmX'><ins id='tNCmX'></ins><ul id='tNCmX'></ul><sub id='tNCmX'></sub></form><legend id='tNCmX'></legend><bdo id='tNCmX'><pre id='tNCmX'><center id='tNCmX'></center></pre></bdo></b><th id='tNCmX'></th></span></q></dt></tr></i><div id='tNCmX'><tfoot id='tNCmX'></tfoot><dl id='tNCmX'><fieldset id='tNCmX'></fieldset></dl></div>
      1. <legend id='tNCmX'><style id='tNCmX'><dir id='tNCmX'><q id='tNCmX'></q></dir></style></legend>
      2. <tfoot id='tNCmX'></tfoot>
          <bdo id='tNCmX'></bdo><ul id='tNCmX'></ul>

      3. <small id='tNCmX'></small><noframes id='tNCmX'>

        通过命令提示符执行 PHP5 脚本时是否可以读取

        时间:2023-10-04
          <legend id='DCtQ7'><style id='DCtQ7'><dir id='DCtQ7'><q id='DCtQ7'></q></dir></style></legend>
        • <tfoot id='DCtQ7'></tfoot>
          <i id='DCtQ7'><tr id='DCtQ7'><dt id='DCtQ7'><q id='DCtQ7'><span id='DCtQ7'><b id='DCtQ7'><form id='DCtQ7'><ins id='DCtQ7'></ins><ul id='DCtQ7'></ul><sub id='DCtQ7'></sub></form><legend id='DCtQ7'></legend><bdo id='DCtQ7'><pre id='DCtQ7'><center id='DCtQ7'></center></pre></bdo></b><th id='DCtQ7'></th></span></q></dt></tr></i><div id='DCtQ7'><tfoot id='DCtQ7'></tfoot><dl id='DCtQ7'><fieldset id='DCtQ7'></fieldset></dl></div>

                  <bdo id='DCtQ7'></bdo><ul id='DCtQ7'></ul>
                    <tbody id='DCtQ7'></tbody>
                • <small id='DCtQ7'></small><noframes id='DCtQ7'>

                • 本文介绍了通过命令提示符执行 PHP5 脚本时是否可以读取 cookie/会话值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我使用命令提示符执行我的 php 脚本时,我需要从 cookie 或会话中读取一些值.我怎样才能做到这一点?

                  I need to read some values from cookie or session when I am executing my php script using command prompt. How can I do that?

                  如何从 Windows 命令提示符访问 cookie 或会话值?

                  How to access cookie or session value from Windows command prompt?

                  推荐答案

                  Cookie 是从用户的 Web 浏览器发送的.当您从命令行执行 php 脚本时,没有浏览器可以发送或接收 cookie.无法访问或保存 cookie,除了您在命令行中传递的参数外,不会向脚本发送任何内容.

                  Cookies are sent from the user's web browser. When you execute a php script from the command line, there is no browser to send or receive cookies. There is no way to access or save cookies and nothing is sent to the script except the parameters you pass on the command line.

                  话虽如此,如果您知道他们的 PHPSESSID cookie,则有一种方法可以读取使用浏览器的人已经访问过的会话.

                  That being said, there is a way to read a session that someone with a browser has already accessed if you know their PHPSESSID cookie.

                  假设有人使用 Web 浏览器访问了您的脚本,并且他们的 PHPSESSID 是 a1b2c3d4,而您想通过他们的会话执行脚本.在命令行执行以下操作.

                  Let's say someone has accessed your script with a web browser and their PHPSESSID is a1b2c3d4, and you want to execute the script with their session. Execute the following at the command line.

                  php -r '$_COOKIE["PHPSESSID"] = "a1b2c3d4"; session_start(); require("path_to_php_script.php");'
                  

                  其中 path_to_php_script.php 是您要执行的 php 脚本的路径.实际上,如果要执行的 php 文件启动会话本身,则不必启动会话.所以,你可能想实际试试这个命令:

                  Where path_to_php_script.php is the path to the php script you want to execute. And actually, you shouldn't have to start the session if the php file you want to execute starts the session itself. So, you may want to actually try this command:

                  php -r '$_COOKIE["PHPSESSID"] = "a1b2c3d4"; require("path_to_php_script.php");'
                  

                  好的,现在假设您不想访问某人的会话,但您只想执行脚本,就像您已经有一个会话一样.只需执行上一个命令,但输入您想要的任何 sessionid.只要您每次调用脚本时使用相同的 PHPSESSID,您的会话就会在调用脚本之间保持不变.

                  OK, now let's say you don't want to access someone's session, but you just want to execute the script as if you already had a session. Just execute the previous command, but put in any sessionid you want. And your session will remain intact between calls to the script as long as you use the same PHPSESSID every time you call the script.

                  这篇关于通过命令提示符执行 PHP5 脚本时是否可以读取 cookie/会话值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Windows 上使用命令行访问 PHP? 下一篇:如何将变量作为标准输入从 PHP 传递到命令行

                  相关文章

                  最新文章

                  • <bdo id='BKKVT'></bdo><ul id='BKKVT'></ul>

                    <small id='BKKVT'></small><noframes id='BKKVT'>

                    <legend id='BKKVT'><style id='BKKVT'><dir id='BKKVT'><q id='BKKVT'></q></dir></style></legend>
                    <tfoot id='BKKVT'></tfoot>
                    1. <i id='BKKVT'><tr id='BKKVT'><dt id='BKKVT'><q id='BKKVT'><span id='BKKVT'><b id='BKKVT'><form id='BKKVT'><ins id='BKKVT'></ins><ul id='BKKVT'></ul><sub id='BKKVT'></sub></form><legend id='BKKVT'></legend><bdo id='BKKVT'><pre id='BKKVT'><center id='BKKVT'></center></pre></bdo></b><th id='BKKVT'></th></span></q></dt></tr></i><div id='BKKVT'><tfoot id='BKKVT'></tfoot><dl id='BKKVT'><fieldset id='BKKVT'></fieldset></dl></div>