0

This problem is on AWS linux instance,in local its working perfact.
Here is my flow:

this file is:test.php

require_once('system/config.php');	
$_SESSION['name']='test';	
echo 'session -name- is:'.$_SESSION['name'];
exit;

Expected Output:
session -name- is:test (its coming.OK)

here i have set session value to test.
so in page session is now live and set to 'test'.

require_once('system/config.php');	
//$_SESSION['name']='test';	
echo 'session -name- is:'.$_SESSION['name'];
exit;

Expected Output:
session -name- is:test (ITS NOT COMING)
My Output:
session -name- is:

Now i have commented first line.
$_SESSION should be test but it is comming blank???

this is PHPINFO:::::>>>>>

Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0

Please help me out... why session value is not working???

4
Contributors
6
Replies
8
Views
7 Years
Discussion Span
Last Post by vibhaJ
0

Now i have commented first line.

Because you have commented out that line, $_SESSION isn't being assigned a value.

Or is the value baing assigned in system/config.php and the problem is that it is not getting passed through?


Zagga

0

you need to intialize the session:

require_once('system/config.php');
session_start();	
$_SESSION['name']='test';//you still need to put something into the array! 	
echo 'session -name- is:'.$_SESSION['name'];
exit;
0

first i execute without comment so session is now set and will reflect to bottom part of that page
But it is a session,so it should be now used anywhere in site....
Please refer phpinfo... might be we can have solution (i haven't :( )
second code with comment is just an example.

@JRM: session_start();
is already in config file.. that why i am able to print it in first case

Edited by vibhaJ: reply

0

like Zagga asked before, where is the value being assigned? from what,where?

0

Hey,
Whether you got two files or are u trying this in the same file itself.
Explain a little more about your work flow.

0

Thanks all for replying...
i got solution. all php code is right.
In linux server there is one folder 'session' in bin folder.
i have changed its permission to 777. and it works

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.