November 18, 2010

Clear a two dimensional session array

Question by acctman

I’d like to clear a specific session, how would I go about doing that.

$_SESSION['files'][]

Answer by Haim Evgi

if you want to unset all the array is :

unset ($_SESSION['files']);

if you want only specific entry to unset is

 unset ($_SESSION['files'][entry]);

Answer by Starx

On addition to above answers, you can remove multiple session variables at once.

unset($_SESSION['file'],$_SESSION['image'],$_SESSION['video']);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!