开发者

Session array element is somehow overwritten

开发者 https://www.devze.com 2023-03-01 15:14 出处:网络
A have a problem with PHP application, that I\'m working on. Main page which consists of some elements has specificaly one which handles sign in form. In that file/element if the sign in button is pre

A have a problem with PHP application, that I'm working on. Main page which consists of some elements has specificaly one which handles sign in form. In that file/element if the sign in button is pressed I try to sign in. If there is no such user in database or no information was inserted ( this is treated same way ) I set specific value for a specific key in sessions array and till the end of the application I do var_dump of $_SESSION array to see it contents. Till the end of the application everything is fine, but in the header when the page loads again after first line which is session_start I var_dump $_SESSION array again and this specific index already has diferent value. I just can't understand where it is set.

Sorry, for non-code explanation, but since it's a commercial application I can't provide any.

UPDATE:

index.php - first line

require_once( dirname( __FILE__ ) . '/header.php' );

h开发者_运维问答eader.php - first lines

session_start();

var_dump( $_SESSION );

loginForm.php - place where value is set.

$_SESSION['lverifier'] = 3;

var_dump( $_SESSION );

index.php - last lines

require_once( dirname( __FILE__ ) . '/footer.php' );

var_dump( $_SESSION );


You'll have to issue session_start() before you can access session variables:

When a visitor accesses your site, PHP will check automatically (if session.auto_start is set to 1) or on your request (explicitly through session_start() or implicitly through session_register()) whether a specific session id has been sent with the request. If this is the case, the prior saved environment is recreated.

[source]

0

精彩评论

暂无评论...
验证码 换一张
取 消