Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8772

Re: Will this set or get a SESSION variable?

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Will this set or get a SESSION variable?
Date 2013-03-20 23:32 -0400
Organization A noiseless patient Spider
Message-ID <kidusi$r5d$2@dont-email.me> (permalink)
References <8dd22b72-62c3-4b3c-b3ec-10ff4d682614@e16g2000yqj.googlegroups.com>

Show all headers | View raw


On 3/20/2013 6:09 PM, David Heller wrote:
>
> I have the following code snippet:
>
> 	if(in_array($name, $this->m_names))
> 		{
> 			$this->m_rules[$name][] = $rule;
> 			return $_SESSION[$name];
>
> 		}
> In the entire script there does not appear to be any assignment to the
> $_SESSION super global
> so would it be fair to say that "return $_SESSION[$name];" not only
> creates a session variable but returns it also? And what is it set
> to?? It appears to me that $_SESSION[$name] = " " or possibly
> something else. There is a bunch of $_SESSION[$somevariable]'s in the
> code I'm looking at. The only reason I care is I would like to not
> have to use any super globals at all but until I can figure out what
> the original author was doing I'm stuck. I have successfully updated
> his code (written in 2001) to work with php 5.3 but its not production
> ready as register_globals has to be on and that's not a good thing. I
> have googled and have seen no example of this type of use of $_SESSION
> or $GLOBALS either.
>
> If you need to see more code please email me directly
>
>
> Thanks
>

No, if the array element doesn't exist, you will get a E_NOTICE message.

Not a good way to program.  Rather, you should be using isset() to 
ensure the array element exists before trying to use it.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Will this set or get a SESSION variable? David Heller <daveh@allheller.net> - 2013-03-20 15:09 -0700
  Re: Will this set or get a SESSION variable? Christoph Becker <cmbecker69@gmx.de> - 2013-03-20 23:53 +0100
    Re: Will this set or get a SESSION variable? David Heller <daveh@allheller.net> - 2013-03-20 17:14 -0700
      Re: Will this set or get a SESSION variable? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-22 15:41 +0100
        Re: Will this set or get a SESSION variable? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-22 17:34 +0100
  Re: Will this set or get a SESSION variable? Robert Heller <heller@deepsoft.com> - 2013-03-20 18:39 -0500
    Re: Will this set or get a SESSION variable? Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-20 23:35 -0400
  Re: Will this set or get a SESSION variable? Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-20 23:32 -0400

csiph-web