note 129663 added to function.session-start
| From: | polygon.co.in@gmail.com | Date: | Mon, 22 Jul 2024 18:16:02 +0000 |
| Subject: | note 129663 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221435@lists.php.net to get a copy of this message | ||
<?php
session_start();
?>
FIRST REQUEST HEADERS
Request
GET /rnd/index.php HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Response
HTTP/1.1 200 OK
Set-Cookie: PHPSESSID=pct9tjl6imbuepdl4scp513962; path=/
// Generates sess_pct9tjl6imbuepdl4scp513962 file in temp directory.
CONSECUTIVE REQUEST HEADERS
Request
GET /rnd/index.php HTTP/1.1
Cookie: PHPSESSID=pct9tjl6imbuepdl4scp513962
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Response
HTTP/1.1 200 OK
<?php
/**
* If we change Cookie: PHPSESSID=pct9tjl6imbuepdl4scp513962 to
* Cookie: PHPSESSID=tempstringvalue via inspect element and refresh the page
* This will create "php_tempstringvalue" file in temp directory.
*/
session_start();
?>
<?php
/**
* If we change Cookie: PHPSESSID=pct9tjl6imbuepdl4scp513962 to
* Cookie: PHPSESSID=tempstringvalue via inspect element and refresh the page
*
* THIS WILL NOT CREATE A NEW FILE. IT IS A READ-ONLY OPERATION.
*/
session_start(
[
'read_and_close' => true
]
);
// Above is a read-only operation.
?>
<?php
session_start(
[
'read_and_close' => true
]
);
/**
* If one wants to modify the session data,
* One can start the session again as below.
* This will enable write operation for storing modified data.
*/
session_start();
?>
<?php
/**
* For all pages where auth is required one can have
*/
if ( isset( $_COOKIE['PHPSESSID'] ) ) {
// Wrong cookie values won't create a new session entry.
// Because its a read only.
session_start( [
'read_and_close' => true,
] );
}
/**
* FOLLOWED BY
* For pages where $_SESSION is to be modified;
* start the session without params as required
*/
session_start();
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 45.118.107.18)
----
Manual Page -- https://php.net/manual/en/function.session-start.php
Edit -- https://main.php.net/note/edit/129663
Del: integrated -- https://main.php.net/note/delete/129663/integrated
Del: useless -- https://main.php.net/note/delete/129663/useless
Del: bad code -- https://main.php.net/note/delete/129663/bad+code
Del: spam -- https://main.php.net/note/delete/129663/spam
Del: non-english -- https://main.php.net/note/delete/129663/non-english
Del: in docs -- https://main.php.net/note/delete/129663/in+docs
Del: other reasons-- https://main.php.net/note/delete/129663
Reject -- https://main.php.net/note/reject/129663
Search -- https://main.php.net/manage/user-notes.php