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