PHP: Can I set Session Variables within Functions?
Question by Guest | 2014-06-30 at 11:02
In one of my PHP scripts, I would like to work with session variables ($_SESSION), also within functions.
Before starting to program this script, I would like to know, whether this is possible at all or if there are any objections for not doing so? So, can I normally work with session variables within functions or can this lead to any problems?
Such as setting a value within a function and having no access to this outside the function or vice versa or any other problems, for example.
Related Topics
PHP: Write array to individual Variables
Tutorial | 0 Comments
PHP: Check if session already exists - Prevent error "A session had already been started"
Question | 3 Answers
PHP: Can I use Arrays as Session Variables?
Question | 1 Answer
PHP: Upload of large Files
Tutorial | 0 Comments
Windows Batch Script: Computer Shutdown
Tutorial | 2 Comments
Delphi: Define global variables
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
$_SESSION is global and can be used everywhere, also within functions.
You only have to take care off always calling session_start() before setting or accessing any $_SESSION variable, otherwise it is not working.
2014-06-30 at 11:02