Jump to content

Recommended Posts

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.

 

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]

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.

 

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.