⊗ppPmSsRm 320 of 447 menu

Deleting Sessions in PHP

Sometimes we may need to delete a specific session variable without affecting the others. This is done using the unset function:

<?php unset($_SESSION['var']); ?>

After executing such code, our variable will become null:

<?php var_dump($_SESSION['var'); // will output null ?>

Here is the counter code from the previous lesson:

<?php session_start(); if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 1; } else { $_SESSION['counter']++; } echo $_SESSION['counter']; ?>

Modify this code so that when the counter reaches the value of 10, the count starts over.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline