Skip to content

Commit 653c1b8

Browse files
authored
Merge pull request #76 from mkbloke/music
Update music cookies to enable SameSite=Strict
2 parents 1a544bc + a11f393 commit 653c1b8

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

modules/music/mp3act_functions.php

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,15 @@ function internalUpdatePlaylist($songs, $count, $length)
11331133
$plId = $db->insert_id();
11341134
if ($plId)
11351135
{
1136-
setcookie('mp3act_playlist_id', $plId, time()+MYTH_PLAYLIST_SAVE_TIME);
1136+
if (PHP_VERSION_ID < 70300) {
1137+
setcookie('mp3act_playlist_id', $plId, time()+MYTH_PLAYLIST_SAVE_TIME, '/; SameSite=Strict');
1138+
} else {
1139+
setcookie('mp3act_playlist_id', $plId, [
1140+
'expires' => time()+MYTH_PLAYLIST_SAVE_TIME,
1141+
'path' => '/',
1142+
'samesite' => 'Strict'
1143+
]);
1144+
}
11371145
return $plId;
11381146
}
11391147
}
@@ -1272,7 +1280,15 @@ function clearPlaylist()
12721280
$pl = internalGetPlaylist();
12731281

12741282
// Trash the cookie (empties the playlist)
1275-
setcookie('mp3act_playlist_id', false, time()-3600);
1283+
if (PHP_VERSION_ID < 70300) {
1284+
setcookie('mp3act_playlist_id', false, time()-3600, '/; SameSite=Strict');
1285+
} else {
1286+
setcookie('mp3act_playlist_id', false, [
1287+
'expires' => time()-3600,
1288+
'path' => '/',
1289+
'samesite' => 'Strict'
1290+
]);
1291+
}
12761292

12771293
if (!empty($pl['playlist_name'])
12781294
&& MYTH_WEB_PLAYLIST_NAME == $pl['playlist_name'])
@@ -1291,7 +1307,15 @@ function deletePlaylist($id)
12911307
if ($id == $_COOKIE['mp3act_playlist_id'])
12921308
{
12931309
$rv = 1;
1294-
setcookie('mp3act_playlist_id', false, time()-3600);
1310+
if (PHP_VERSION_ID < 70300) {
1311+
setcookie('mp3act_playlist_id', false, time()-3600, '/; SameSite=Strict');
1312+
} else {
1313+
setcookie('mp3act_playlist_id', false, [
1314+
'expires' => time()-3600,
1315+
'path' => '/',
1316+
'samesite' => 'Strict'
1317+
]);
1318+
}
12951319
}
12961320

12971321
$query = 'DELETE FROM music_playlists '.
@@ -1416,7 +1440,15 @@ function playlist_add($type, $itemid)
14161440
if ('loadplaylist' == $type)
14171441
{
14181442
clearPlaylist();
1419-
setcookie('mp3act_playlist_id', $itemid, time()+MYTH_PLAYLIST_SAVE_TIME);
1443+
if (PHP_VERSION_ID < 70300) {
1444+
setcookie('mp3act_playlist_id', $itemid, time()+MYTH_PLAYLIST_SAVE_TIME, '/; SameSite=Strict');
1445+
} else {
1446+
setcookie('mp3act_playlist_id', $itemid, [
1447+
'expires' => time()+MYTH_PLAYLIST_SAVE_TIME,
1448+
'path' => '/',
1449+
'samesite' => 'Strict'
1450+
]);
1451+
}
14201452
$output[0] = 1;
14211453
return $output;
14221454
}

0 commit comments

Comments
 (0)