session_basic3.phpt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. --TEST--
  2. Test basic function : variation3 use_trans_sid
  3. --INI--
  4. session.use_strict_mode=0
  5. session.use_only_cookies=0
  6. session.use_trans_sid=1
  7. session.save_handler=files
  8. session.hash_bits_per_character=4
  9. session.hash_function=0
  10. session.gc_probability=1
  11. session.gc_divisor=1000
  12. session.gc_maxlifetime=300
  13. session.save_path=
  14. session.name=PHPSESSID
  15. url_rewriter.hosts=
  16. --EXTENSIONS--
  17. session
  18. --SKIPIF--
  19. <?php include('skipif.inc'); ?>
  20. --FILE--
  21. <?php
  22. ob_start();
  23. echo "*** Testing basic session functionality : variation3 use_trans_sid ***\n";
  24. /*
  25. echo "*** test output_add_rewrite_var() ***\n";
  26. output_add_rewrite_var('var', 'value');
  27. echo '
  28. <a href="/">test</a>
  29. <a href="/#bar">test</a>
  30. <a href="/?foo">test</a>
  31. <a href="/?foo#bar">test</a>
  32. <a href="/?foo=var">test</a>
  33. <a href="/?foo=var#bar">test</a>
  34. <a href="file.php">test</a>
  35. <a href="file.php?foo">test</a>
  36. <a href="file.php?foo=var">test</a>
  37. <a href="http://php.net">test</a>
  38. <a href="http://php.net/">test</a>
  39. <a href="http://php.net/#bar">test</a>
  40. <a href="http://php.net/?foo">test</a>
  41. <a href="http://php.net/?foo#bar">test</a>
  42. <a href="http://php.net/?foo=var">test</a>
  43. <a href="http://php.net/?foo=var#bar">test</a>
  44. <a href="http://php.net/file.php">test</a>
  45. <a href="http://php.net/file.php#bar">test</a>
  46. <a href="http://php.net/file.php?foo">test</a>
  47. <a href="http://php.net/file.php?foo#bar">test</a>
  48. <a href="http://php.net/file.php?foo=var">test</a>
  49. <a href="http://php.net/file.php?foo=var#bar">test</a>
  50. <a href="http://php.net/some/path/file.php">test</a>
  51. <a href="http://php.net/some/path/file.php?foo">test</a>
  52. <a href="http://php.net/some/path/file.php?foo=var">test</a>
  53. <a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
  54. <a href="https://php.net">test</a>
  55. <a href="https://php.net/">test</a>
  56. <a href="https://php.net/?foo=var#bar">test</a>
  57. <a href="https://php.net/file.php">test</a>
  58. <a href="https://php.net/file.php?foo=var#bar">test</a>
  59. <a href="https://php.net/some/path/file.php">test</a>
  60. <a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
  61. <a href="https://php.net:8443">test</a>
  62. <a href="https://php.net:8443/">test</a>
  63. <a href="https://php.net:8443/?foo=var#bar">test</a>
  64. <a href="https://php.net:8443/file.php">test</a>
  65. <a href="https://php.net:8443/file.php?foo=var#bar">test</a>
  66. <a href="https://php.net:8443/some/path/file.php">test</a>
  67. <a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
  68. <a href="//php.net">test</a>
  69. <a href="//php.net/">test</a>
  70. <a href="//php.net/#bar">test</a>
  71. <a href="//php.net/?foo">test</a>
  72. <a href="//php.net/?foo#bar">test</a>
  73. <a href="//php.net/?foo=var">test</a>
  74. <a href="//php.net/?foo=var#bar">test</a>
  75. <a href="//php.net/file.php">test</a>
  76. <a href="//php.net/file.php#bar">test</a>
  77. <a href="//php.net/file.php?foo">test</a>
  78. <a href="//php.net/file.php?foo#bar">test</a>
  79. <a href="//php.net/file.php?foo=var">test</a>
  80. <a href="//php.net/file.php?foo=var#bar">test</a>
  81. <a href="//php.net/some/path/file.php">test</a>
  82. <a href="//php.net/some/path/file.php?foo">test</a>
  83. <a href="//php.net/some/path/file.php?foo=var">test</a>
  84. <a href="//php.net/some/path/file.php?foo=var#bar">test</a>
  85. <form action="script.php" method="post">
  86. <input type="text" name="test1"></input>
  87. <input type="text" name="test2" />
  88. </form>
  89. ';
  90. output_reset_rewrite_vars();
  91. */
  92. echo "*** Test trans sid ***\n";
  93. ob_start();
  94. $session_id = 'session-basic3';
  95. session_id($session_id);
  96. session_start();
  97. // Should add session ID to relative URL only for SECURITY
  98. echo '
  99. <a href="/">test</a>
  100. <a href="/path">test</a>
  101. <a href="/path/">test</a>
  102. <a href="/path/?foo=var">test</a>
  103. <a href="../">test</a>
  104. <a href="../path">test</a>
  105. <a href="../path/">test</a>
  106. <a href="../path/?foo=var">test</a>
  107. <a href="/#bar">test</a>
  108. <a href="/path/#bar">test</a>
  109. <a href="/path/?foo=var#bar">test</a>
  110. <a href="../#bar">test</a>
  111. <a href="../path/#bar">test</a>
  112. <a href="../path/?foo=var#bar">test</a>
  113. <a href="/?foo">test</a>
  114. <a href="/?foo#bar">test</a>
  115. <a href="/?foo=var">test</a>
  116. <a href="/?foo=var#bar">test</a>
  117. <a href="../?foo">test</a>
  118. <a href="../?foo#bar">test</a>
  119. <a href="../?foo=var">test</a>
  120. <a href="../?foo=var#bar">test</a>
  121. <a href="file.php">test</a>
  122. <a href="file.php?foo">test</a>
  123. <a href="file.php?foo=var">test</a>
  124. <a href="file.php?foo=var#bar">test</a>
  125. <a href="../file.php">test</a>
  126. <a href="../file.php?foo">test</a>
  127. <a href="../file.php?foo=var">test</a>
  128. <a href="../file.php?foo=var#bar">test</a>
  129. <a href="http://php.net">test</a>
  130. <a href="http://php.net/">test</a>
  131. <a href="http://php.net/#bar">test</a>
  132. <a href="http://php.net/?foo">test</a>
  133. <a href="http://php.net/?foo#bar">test</a>
  134. <a href="http://php.net/?foo=var">test</a>
  135. <a href="http://php.net/?foo=var#bar">test</a>
  136. <a href="http://php.net/file.php">test</a>
  137. <a href="http://php.net/file.php#bar">test</a>
  138. <a href="http://php.net/file.php?foo">test</a>
  139. <a href="http://php.net/file.php?foo#bar">test</a>
  140. <a href="http://php.net/file.php?foo=var">test</a>
  141. <a href="http://php.net/file.php?foo=var#bar">test</a>
  142. <a href="http://php.net/some/path/file.php">test</a>
  143. <a href="http://php.net/some/path/file.php?foo">test</a>
  144. <a href="http://php.net/some/path/file.php?foo=var">test</a>
  145. <a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
  146. <a href="https://php.net">test</a>
  147. <a href="https://php.net/">test</a>
  148. <a href="https://php.net/?foo=var#bar">test</a>
  149. <a href="https://php.net/file.php">test</a>
  150. <a href="https://php.net/file.php?foo=var#bar">test</a>
  151. <a href="https://php.net/some/path/file.php">test</a>
  152. <a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
  153. <a href="https://php.net:8443">test</a>
  154. <a href="https://php.net:8443/">test</a>
  155. <a href="https://php.net:8443/?foo=var#bar">test</a>
  156. <a href="https://php.net:8443/file.php">test</a>
  157. <a href="https://php.net:8443/file.php?foo=var#bar">test</a>
  158. <a href="https://php.net:8443/some/path/file.php">test</a>
  159. <a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
  160. <a href="//php.net">test</a>
  161. <a href="//php.net/">test</a>
  162. <a href="//php.net/#bar">test</a>
  163. <a href="//php.net/?foo">test</a>
  164. <a href="//php.net/?foo#bar">test</a>
  165. <a href="//php.net/?foo=var">test</a>
  166. <a href="//php.net/?foo=var#bar">test</a>
  167. <a href="//php.net/file.php">test</a>
  168. <a href="//php.net/file.php#bar">test</a>
  169. <a href="//php.net/file.php?foo">test</a>
  170. <a href="//php.net/file.php?foo#bar">test</a>
  171. <a href="//php.net/file.php?foo=var">test</a>
  172. <a href="//php.net/file.php?foo=var#bar">test</a>
  173. <a href="//php.net/some/path/file.php">test</a>
  174. <a href="//php.net/some/path/file.php?foo">test</a>
  175. <a href="//php.net/some/path/file.php?foo=var">test</a>
  176. <a href="//php.net/some/path/file.php?foo=var#bar">test</a>
  177. <form action="script.php" method="post">
  178. <input type="text" name="test1"></input>
  179. <input type="text" name="test2" />
  180. </form>
  181. <form action="../script.php" method="post">
  182. <input type="text" name="test1"></input>
  183. <input type="text" name="test2" />
  184. </form>
  185. <form action="/path/script.php" method="post">
  186. <input type="text" name="test1"></input>
  187. <input type="text" name="test2" />
  188. </form>
  189. <form action="../path/script.php" method="post">
  190. <input type="text" name="test1"></input>
  191. <input type="text" name="test2" />
  192. </form>
  193. <form method="post" action="http://php.net/script.php">
  194. <input type="text" name="test1"></input>
  195. <input type="text" name="test2" />
  196. </form>
  197. <form method="post" action="https://php.net/script.php">
  198. <input type="text" name="test1"></input>
  199. <input type="text" name="test2" />
  200. </form>
  201. <form method="post" action="//php.net/script.php">
  202. <input type="text" name="test1"></input>
  203. <input type="text" name="test2" />
  204. </form>
  205. ';
  206. var_dump(session_commit());
  207. echo "*** Cleanup ***\n";
  208. var_dump(session_start());
  209. var_dump(session_id());
  210. var_dump(session_destroy());
  211. ob_end_flush();
  212. ?>
  213. --EXPECT--
  214. *** Testing basic session functionality : variation3 use_trans_sid ***
  215. *** Test trans sid ***
  216. <a href="/?PHPSESSID=session-basic3">test</a>
  217. <a href="/path?PHPSESSID=session-basic3">test</a>
  218. <a href="/path/?PHPSESSID=session-basic3">test</a>
  219. <a href="/path/?foo=var&PHPSESSID=session-basic3">test</a>
  220. <a href="../?PHPSESSID=session-basic3">test</a>
  221. <a href="../path?PHPSESSID=session-basic3">test</a>
  222. <a href="../path/?PHPSESSID=session-basic3">test</a>
  223. <a href="../path/?foo=var&PHPSESSID=session-basic3">test</a>
  224. <a href="/?PHPSESSID=session-basic3#bar">test</a>
  225. <a href="/path/?PHPSESSID=session-basic3#bar">test</a>
  226. <a href="/path/?foo=var&PHPSESSID=session-basic3#bar">test</a>
  227. <a href="../?PHPSESSID=session-basic3#bar">test</a>
  228. <a href="../path/?PHPSESSID=session-basic3#bar">test</a>
  229. <a href="../path/?foo=var&PHPSESSID=session-basic3#bar">test</a>
  230. <a href="/?foo&PHPSESSID=session-basic3">test</a>
  231. <a href="/?foo&PHPSESSID=session-basic3#bar">test</a>
  232. <a href="/?foo=var&PHPSESSID=session-basic3">test</a>
  233. <a href="/?foo=var&PHPSESSID=session-basic3#bar">test</a>
  234. <a href="../?foo&PHPSESSID=session-basic3">test</a>
  235. <a href="../?foo&PHPSESSID=session-basic3#bar">test</a>
  236. <a href="../?foo=var&PHPSESSID=session-basic3">test</a>
  237. <a href="../?foo=var&PHPSESSID=session-basic3#bar">test</a>
  238. <a href="file.php?PHPSESSID=session-basic3">test</a>
  239. <a href="file.php?foo&PHPSESSID=session-basic3">test</a>
  240. <a href="file.php?foo=var&PHPSESSID=session-basic3">test</a>
  241. <a href="file.php?foo=var&PHPSESSID=session-basic3#bar">test</a>
  242. <a href="../file.php?PHPSESSID=session-basic3">test</a>
  243. <a href="../file.php?foo&PHPSESSID=session-basic3">test</a>
  244. <a href="../file.php?foo=var&PHPSESSID=session-basic3">test</a>
  245. <a href="../file.php?foo=var&PHPSESSID=session-basic3#bar">test</a>
  246. <a href="http://php.net">test</a>
  247. <a href="http://php.net/">test</a>
  248. <a href="http://php.net/#bar">test</a>
  249. <a href="http://php.net/?foo">test</a>
  250. <a href="http://php.net/?foo#bar">test</a>
  251. <a href="http://php.net/?foo=var">test</a>
  252. <a href="http://php.net/?foo=var#bar">test</a>
  253. <a href="http://php.net/file.php">test</a>
  254. <a href="http://php.net/file.php#bar">test</a>
  255. <a href="http://php.net/file.php?foo">test</a>
  256. <a href="http://php.net/file.php?foo#bar">test</a>
  257. <a href="http://php.net/file.php?foo=var">test</a>
  258. <a href="http://php.net/file.php?foo=var#bar">test</a>
  259. <a href="http://php.net/some/path/file.php">test</a>
  260. <a href="http://php.net/some/path/file.php?foo">test</a>
  261. <a href="http://php.net/some/path/file.php?foo=var">test</a>
  262. <a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
  263. <a href="https://php.net">test</a>
  264. <a href="https://php.net/">test</a>
  265. <a href="https://php.net/?foo=var#bar">test</a>
  266. <a href="https://php.net/file.php">test</a>
  267. <a href="https://php.net/file.php?foo=var#bar">test</a>
  268. <a href="https://php.net/some/path/file.php">test</a>
  269. <a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
  270. <a href="https://php.net:8443">test</a>
  271. <a href="https://php.net:8443/">test</a>
  272. <a href="https://php.net:8443/?foo=var#bar">test</a>
  273. <a href="https://php.net:8443/file.php">test</a>
  274. <a href="https://php.net:8443/file.php?foo=var#bar">test</a>
  275. <a href="https://php.net:8443/some/path/file.php">test</a>
  276. <a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
  277. <a href="//php.net">test</a>
  278. <a href="//php.net/">test</a>
  279. <a href="//php.net/#bar">test</a>
  280. <a href="//php.net/?foo">test</a>
  281. <a href="//php.net/?foo#bar">test</a>
  282. <a href="//php.net/?foo=var">test</a>
  283. <a href="//php.net/?foo=var#bar">test</a>
  284. <a href="//php.net/file.php">test</a>
  285. <a href="//php.net/file.php#bar">test</a>
  286. <a href="//php.net/file.php?foo">test</a>
  287. <a href="//php.net/file.php?foo#bar">test</a>
  288. <a href="//php.net/file.php?foo=var">test</a>
  289. <a href="//php.net/file.php?foo=var#bar">test</a>
  290. <a href="//php.net/some/path/file.php">test</a>
  291. <a href="//php.net/some/path/file.php?foo">test</a>
  292. <a href="//php.net/some/path/file.php?foo=var">test</a>
  293. <a href="//php.net/some/path/file.php?foo=var#bar">test</a>
  294. <form action="script.php" method="post"><input type="hidden" name="PHPSESSID" value="session-basic3" />
  295. <input type="text" name="test1"></input>
  296. <input type="text" name="test2" />
  297. </form>
  298. <form action="../script.php" method="post"><input type="hidden" name="PHPSESSID" value="session-basic3" />
  299. <input type="text" name="test1"></input>
  300. <input type="text" name="test2" />
  301. </form>
  302. <form action="/path/script.php" method="post"><input type="hidden" name="PHPSESSID" value="session-basic3" />
  303. <input type="text" name="test1"></input>
  304. <input type="text" name="test2" />
  305. </form>
  306. <form action="../path/script.php" method="post"><input type="hidden" name="PHPSESSID" value="session-basic3" />
  307. <input type="text" name="test1"></input>
  308. <input type="text" name="test2" />
  309. </form>
  310. <form method="post" action="http://php.net/script.php">
  311. <input type="text" name="test1"></input>
  312. <input type="text" name="test2" />
  313. </form>
  314. <form method="post" action="https://php.net/script.php">
  315. <input type="text" name="test1"></input>
  316. <input type="text" name="test2" />
  317. </form>
  318. <form method="post" action="//php.net/script.php">
  319. <input type="text" name="test1"></input>
  320. <input type="text" name="test2" />
  321. </form>
  322. bool(true)
  323. *** Cleanup ***
  324. bool(true)
  325. string(14) "session-basic3"
  326. bool(true)