sayedsohail Posted August 2, 2007 Share Posted August 2, 2007 Sorry guys bringing this to you at this moment, unfortunately the session array is showing empty, when i jumped to second level of links in my project. i got a index page, which is login, works perfectly fine start sessions and registered the user. and take me to the appropriate page and print_r($_SESSION); prints all the stored values inside it. But when i clicked any links on my second level, the print_r($_SESSION); is showing empty array(), its strange although i am using session_start on every page. i got 15 pages on second level(i mean links from this page to another .php pages) and every page shows empty array(); although every page got session_start(); and validation if(strlen(trim($_SESSION['SESS_USERNAME'])) > 1) at the begining of the file before anything else. I don't know what to do? its KILLING me for weeks. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/ Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 can we see some sample codes Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314469 Share on other sites More sharing options...
sayedsohail Posted August 2, 2007 Author Share Posted August 2, 2007 the sample code for session_start: session_start; if(strlen(trim($_SESSION['SESS_USERNAME'])) > 1) $currentTimeoutInSecs = ini_get("session.gc_maxlifetime"); print_r($_SESSION); print $currentTimeoutInSecs; this is works fine when i login and prints the array with all session values and session time 1440 on the redirected page administrator.php, but when i click the link on administrator.php <a href='test.php'>view report</a> the session array is printing empty. test.php <?php [code]session_start; if(strlen(trim($_SESSION['SESS_USERNAME'])) > 1) $currentTimeoutInSecs = ini_get("session.gc_maxlifetime"); print_r($_SESSION); print $currentTimeoutInSecs; ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314472 Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 try to session_start(); not session_start; Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314479 Share on other sites More sharing options...
btherl Posted August 2, 2007 Share Posted August 2, 2007 Are you a perl user? In PHP, you can't leave out the brackets from a function call. It just won't work. The only exceptions are builtins like print, echo and exit. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314480 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 i am sorry it was a typo , actually i am using session_start(); in all my files. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314499 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 may we see how you initiliaze the session Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314503 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 its not initalizing cause, it prints the session value on the redirected page, and than the link from this page which follows the next pages showing empty session array and as i said earlier i got 15-20 pages and every page is the same problem, although i used session_start(); at the begining on every page. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314515 Share on other sites More sharing options...
redarrow Posted August 3, 2007 Share Posted August 3, 2007 how u setting the session $varable please. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314520 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 i guess you have to have something like this $_SESSION['test']='value'; now if you have session start in every page im sure it will be set as it is Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314524 Share on other sites More sharing options...
btherl Posted August 3, 2007 Share Posted August 3, 2007 Can you copy and paste your script which is not able to access the session data? Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314533 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 GUYS, print_r prints the session values on the redirected page, that means it intialized and stored the values i set in my login page. the redirected page admin.php print_r prints all the values and only from here if i click any link to other pages, the session array is showing empty. test.php having problem, the code is listed above. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314535 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 yes we know thats y Can you copy and paste your script which is not able to access the session data? Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314536 Share on other sites More sharing options...
redarrow Posted August 3, 2007 Share Posted August 3, 2007 Show us test.php please. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314537 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 test.php <?php session_start(); if(strlen(trim($_SESSION['SESS_USERNAME'])) > 1) $currentTimeoutInSecs = ini_get("session.gc_maxlifetime"); print_r($_SESSION); print $currentTimeoutInSecs;?> Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314538 Share on other sites More sharing options...
redarrow Posted August 3, 2007 Share Posted August 3, 2007 get rid of ths ok $currentTimeoutInSecs = ini_get("session.gc_maxlifetime"); Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314539 Share on other sites More sharing options...
btherl Posted August 3, 2007 Share Posted August 3, 2007 If the session data isn't set, it's probably because the browser did not send the cookie. Are you using firefox or IE? We can try debugging it from the browser side. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314581 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 its acting same on both IE 7 AND firefox. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314836 Share on other sites More sharing options...
sayedsohail Posted August 3, 2007 Author Share Posted August 3, 2007 oh finally i am somewhere close now, my hyperlinks to other files works fine. and print_r prints all the contents of the array. But there is one problem, if i include all my hyperlinks in navgiation.php and call this file using require_once("navigation.php"); the links appear on the page, but when i click this links the session array is showing no values, just empty. yes offcourse the first line of navigation.php is <?php session_start(); , although i tried removing this file to see any positive results but no difference, all the link coming from require_once("navigation.php") clears my session array. Quote Link to comment https://forums.phpfreaks.com/topic/63118-solved-session-array-showing-empty-in-some-files/#findComment-314997 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.