note 48326 added to function.sha1

From: Date: Sun, 19 Dec 2004 16:18:43 +0000
Subject: note 48326 added to function.sha1
Groups: php.notes 
Request: Send a blank email to php-notes+get-82046@lists.php.net to get a copy of this message
You can also use sha1() to create a fixed sized ID based on the folderpath containing the performing script. Imagine an environment where multiple instances of a script are running simultaneously, making use of session variables (a good example would be thumbnaildirectories that each contain an instance of a thumbnailmanager). To prevent your $_SESSION array from getting influenced by other scripts that are on the same server and run from the same browserwindow (and thus having the same session ID), use the following approach: session_start(); $myDir = sha1(dirname(__FILE__)); $_SESSION[$myDir]['var'] = etc; instead of just using $_SESSION['var'] = etc; This way your userauthentication and shoppingcart data won't get mixed up. The use of sha1() also prevents strange symbols or spaces in the folderpath messing up the ID, and makes sure the ID has a constant size regardless the length of the path. ---- Manual Page -- http://www.php.net/manual/en/function.sha1.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48326 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48326&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48326&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82046) next »