Description of the function: http://php.net/manual/zh/function.tempnam.php
The Tempnam function can produce a file name with a unique file name in the specified directory. Typically applies to custom session file names.
This function is still very useful. For example, if we are going to use curl to forge a session, then we can use it.
Related information: http://www.phpjx.com/show_5919.html
<?php function Vlogin ($url, $request) {session_start (); $cookie _jar = Tempnam ('./tmp ', ' cookie ');//A temporary file that generates a random file name in the current directory $ch = Curl_init ($url); Initialize the Curl module curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1);//post Way to submit curl_setopt ($ch, Curlopt_postfields, $request);//To submit the content//return $cookie_ The cookie information from the jar is stored in the $cookie_jar file curl_setopt ($ch, Curlopt_cookiejar, $cookie _jar); $xianshi =curl_exec ($ch); Curl_close ($ch); Get data after login $curl = "http://phpjx.local.com/login/session/show.php";//the page to crawl the page, which has session judgment permission $ch =curl_ Init ($curl); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, "sitename=phpjx.com&siteurl=http://www.phpjx.com"); curl_setopt ($ch, Curlopt_cookiefile, $cookie _jar); $xianshi =curl_exec ($ch); Curl_close ($ch); return $xianshi; } $url = "http://phpjx.local.com/login/session/check.php";//We pass a value to the page to generate the session and then pass it to the page you want to crawl $request = "username =yansy "; Echo Vlogin ($url, $request)?>
Can self-Baidu a bit of relevant information.
php function Tempnam ()