Home  >  Article  >  Backend Development  >  How to get cookies in php firefox

How to get cookies in php firefox

王林
王林Original
2019-09-26 11:49:112342browse

How to get cookies in php firefox

1. PHP environment construction

2. Java running environment construction. It needs to be explained here that the selenium running file is a jar package. You must set up the java running environment. environment to enable selenium.

3. Download the selenium file and download the jar package file of selenium-server-standalone-3.4.0.jar.

4. Install a browser. It is recommended that you use Google or Firefox browser. Please note that you need to configure environment variables for the browser. Otherwise, the browser cannot be launched later.

5. Download the browser driver file (note here: be sure to download the driver file that matches the browser version installed on this machine). The driver file name used by Google browser is: chromedriver. The driver file name of Firefox is: geckodriver.exe (go to selenium official website to download, select java).

How to get cookies in php firefox

Note: The downloaded driver file must be placed in the root directory of php

How to get cookies in php firefox

6. Download the demo file of PHP selenium

7. After writing the demo, you can test it. First, run the downloaded selenium jar package file, and enter the directory where you placed the selenium file in the cmd command line. Then execute the following command

(Note: You need to configure the java running environment variable in the second step)

 java -jar selenium-server-standalone-3.4.0.jar

If the following prompt appears on your command line, that is The startup was successful.

How to get cookies in php firefox

8. You can run your demo.php file in the cmd command line. If you successfully launch the browser, congratulations. For how to operate the browser, how to log in, how to obtain cookie information, etc., please directly refer to the PHP selenium documentation.

Finally, I would like to remind everyone to pay attention to a few points (also some of the problems I encountered in the deployment environment):

(1) Version problem: Be sure to download browser plug-ins and selenium Choose the right version

(2) Problem with the location of the browser plug-in: I encountered this problem when I was doing it, and then I threw it directly into the php directory and solved it

(3) In When logging in specifically, php throws an exception, which means that the button to be clicked is not found on the page being operated (I choose to locate the element by id here). Even if I change it to locate it by name, it cannot be located. I am surprised. Strange, I flipped through the document decisively and saw the tips in the document that if you use , you must switch to the specified iframe to locate the element.

Recommended tutorial: PHP video tutorial

The above is the detailed content of How to get cookies in php firefox. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn