Reply to Re: Global Variables

Your name:

Reply:


Posted by Matthew Weier O'Phinney on 04/28/05 18:10

* Dan <dan@entropy.homelinux.org>:
> I taught myself PHP before the frenzy over register_globals.
> After a reasonable break from the language, I'm back for more.
>
> I'm building a site where I'll be holding a lot of variables in memory
> for each session. How do I do that? Apparently I can't use
> session_register() if register_globals is turned off. I've read a little
> about the consequences of writing bad scripts with register_globals on
> ... I'm fine with this explanation. I agree that I don't want people
> injecting variables into my session. What I want is for ME to be able to
> set variables and remember them throughout the session. How do I do that?

Use of session_register() is deprecated in favor of direct access to the
$_SESSION array -- which is present if session_start() has been called:

<?php
session_start();
$_SESSION['foo'] = 'bar'; // retrieve a session variable
$bar = $_SESSION['bar']; // set a session variable
?>

--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация