Saturday, December 6, 2008

Overcoming Session Error Warning

Finding error when doing develop, not something you should fear. Because every error that occurs is a special opportunity to become better application again.

This article will discuss two types of errors that occur in session procedure in PHP and is a continuation of the article about the PHP Session.

Okay, so save your reading time, following detail the case:

ERROR 1
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be Advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

The message was conveyed by the PHP session variables associated with that you create. Differentiate the two examples following script:

example 1:
session_start ();
session_register ( "usermember");
session_register ( "passmember");
$ usermember = $ datauser [userid];
$ passmember = $ datauser [password];

example 2:
session_start ();
session_register ( "usermember");
session_register ( "passmember");
$ _SESSION [ 'Usermember'] = $ datauser [userid];
$ _SESSION [ 'Passmember'] = $ datauser [password];

Warning error above will occur when you use a command script as an example 1. The solution, of course, you should use the script as an example 2. So as a small conclusion, the session you need assertiveness to say whether a variable is a session or not. If planned as a session, then from the beginning had to be confirmed with the command $ _SESSION [ 'namavariabel'].


ERROR 2
Warning: session_start () [function.session-start]: Can not send session cache limiter - headers already sent (output started at D: \ xampplite \ htdocs \ donation \ koneksi.php: 4) in D: \ xampplite \ htdocs \ donors \ login.php on line 16

2 error messages on your face will be if you put the command session_start (); not in the right place. It commands this one quite selfish. He must be placed before anything else. Consider two examples of the following script:

example 1:
if ($ usermember == $ datauser [userid])
(
session_start ();
session_register ( "usermember");
session_register ( "passmember");
$ _SESSION [ 'Usermember'] = $ datauser [userid];
$ _SESSION [ 'Passmember'] = $ datauser [password];
)

example 2:
session_start ();
if ($ usermember == $ datauser [userid])
(
session_register ( "usermember");
session_register ( "passmember");
$ _SESSION [ 'Usermember'] = $ datauser [userid];
$ _SESSION [ 'Passmember'] = $ datauser [password];
)

In example 1, session_start (); placed after the branching order if (). That means the command was run after other procedures. Well, to avoid messages like ERROR 2, we recommend you use a command like the example 2.
Contribute a better translation

No comments:

Post a Comment