marcelog / Ding

DI ( Dependency Injection: Setter, Constructor, Method), AOP ( Aspect Oriented Programming ), Events support, xml, yaml, and annotations (including some JSR 250 and JSR 330, like @Configuration and @Bean ala java configuration) , lightweight, simple, and quick MVC ( Model View Controller ), syslog, tcp client and server, with non blocking sockets, custom error, signal, and exception handling through events. Needs PHP 5.3, very similar to seasar, spring ( java ) . Can be deployed as a PHAR file.
http://marcelog.github.com/Ding
Apache License 2.0
121 stars 26 forks source link

global $_SESSION; #102

Closed olamedia closed 13 years ago

olamedia commented 13 years ago

I lol'd, $_SESSION is a superglobal, using global keyword doesn't make any sense here

olamedia commented 13 years ago

You must better check if session was created or not. When not, $_SESSION will not be saved

marcelog commented 13 years ago

I assume you're talking about the HttpSession helper. The HttpFrontController already does a session_start() in the handle() method. This is the intended way to use the HttpSession, with the whole MVC (it wouldn't make much sense to only use the HttpSession and not the rest of the MVC).

This call to session_start() will always start a session, so $_SESSION will always be set.

Did you find any bugs regarding this?

olamedia commented 13 years ago

this is not really a bug, but $_SESSION is always accessible from anywhere, global $_SESSION does nothing. Also, using global is a bad practice, just forget about this keyword.

olamedia commented 13 years ago

http://ru.php.net/manual/en/language.variables.superglobals.php

marcelog commented 13 years ago

Closed by af812a98447e2c7fd819b0c68baad2c3a8ab6f1b removed global keyword for $_SESSION

olamedia commented 13 years ago

I think, your primary language is java, so you just didn't know about this.

marcelog commented 13 years ago

Thanks for the tip. I missed that in the manual. The keyword was removed in the last commit.