Store array on Session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Store array on Session

Post by johniem »

I'm trying to store an array on session but it doesn't seem to working...
I'm creating a CMS using tinymce and when a user creating a page I wan't to keep the path of the images that user upload on the ftp and when he finishes just check which images he finally keep and delete the orphan ones.

Code: Select all

 
if(isset($_SESSION['images']) || $_SESSION['images'] != "" || $_SESSION['images'] != null){
            
            $imagesArray = array();
            
            foreach ($_SESSION['images'] as $key=>$value)
                array_push($imagesArray,$value);
 
            foreach ($imagesArray as $key => $value){
            
                if ($value == $imageToUpload)
                    $imgExist = true;
                else
                    $imgExist = false;
            }
 
            if ($imgExist)
                $_SESSION['images']=$imagesArray;
            else{
                array_push($imagesArray,$imageToUpload);
                $_SESSION['images']=$imagesArray;
            }                           
        
        }else{
            $imagesArray = array($imageToUpload);
            $_SESSION['images']=$imagesArray;           
        }
 
I'm not using any session_unset() and when i'm trying to use isset($_SESSION['images']) it's not returning anything (no "false" neither "true").
Post Reply