By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Session Variables in Red Hat?

P: 2
Hi,

I am attempting to use php session variables on a server which is running Red Hat Linux, but the variables don't seem to be getting passed between pages. I have tried the same exact test script on my third party webhost, and it works just fine. Does anyone know of anything that needs to be changed in a default Red Hat php setup?

This is the test script that I am using:
http://php.about.com/od/advancedphp/ss/php_sessions.htm

This is what I was given as the default setup for redhat:
Expand|Select|Wrap|Line Numbers
  1. [Session]
  2. ; Handler used to store/retrieve data.
  3. session.save_handler = files
  4.  
  5. ; Argument passed to save_handler.  In the case of files, this is the path
  6. ; where data files are stored. Note: Windows users have to change this
  7. ; variable in order to use PHP's session functions.
  8. session.save_path = /var/lib/php/session
  9.  
  10. ; Whether to use cookies.
  11. session.use_cookies = 1
  12.  
  13. ; This option enables administrators to make their users invulnerable to
  14. ; attacks which involve passing session ids in URLs; defaults to 0.
  15. ; session.use_only_cookies = 1
  16.  
  17. ; Name of the session (used as cookie name).
  18. session.name = PHPSESSID
  19.  
  20. ; Initialize session on request startup.
  21. session.auto_start = 0
  22.  
  23. ; Lifetime in seconds of cookie or, if 0, until browser is restarted.
  24. session.cookie_lifetime = 0
  25.  
  26. ; The path for which the cookie is valid.
  27. session.cookie_path = /
  28.  
  29. ; The domain for which the cookie is valid.
  30. session.cookie_domain =
  31.  
  32. ; Handler used to serialize data.  php is the standard serializer of PHP.
  33. session.serialize_handler = php
  34.  
  35. ; Define the probability that the 'garbage collection' process is started
  36. ; on every session initialization.
  37. ; The probability is calculated by using gc_probability/gc_divisor,
  38. ; e.g. 1/100 means there is a 1% chance that the GC process starts
  39. ; on each request.
  40.  
  41. session.gc_probability = 1
  42. session.gc_divisor     = 1000
  43.  
  44. ; After this number of seconds, stored data will be seen as 'garbage' and
  45. ; cleaned up by the garbage collection process.
  46. session.gc_maxlifetime = 1440
  47.  
  48. ; PHP 4.2 and less have an undocumented feature/bug that allows you to
  49. ; to initialize a session variable in the global scope, albeit register_globals
  50. ; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
  51. ; You can disable the feature and the warning separately. At this time,
  52. ; the warning is only displayed, if bug_compat_42 is enabled.
  53.  
  54. session.bug_compat_42 = 0
  55. session.bug_compat_warn = 1
  56.  
  57. ; Check HTTP Referer to invalidate externally stored URLs containing ids.
  58. ; HTTP_REFERER has to contain this substring for the session to be
  59. ; considered as valid.
  60. session.referer_check =
  61.  
  62. ; How many bytes to read from the file.
  63. session.entropy_length = 0
  64.  
  65. ; Specified here to create the session id.
  66. session.entropy_file =
  67.  
  68. ;session.entropy_length = 16
  69.  
  70. ;session.entropy_file = /dev/urandom
  71.  
  72. ; Set to {nocache,private,public,} to determine HTTP caching aspects.
  73. ; or leave this empty to avoid sending anti-caching headers.
  74. session.cache_limiter = nocache
  75.  
  76. ; Document expires after n minutes.
  77. session.cache_expire = 180
  78.  
  79. ; trans sid support is disabled by default.
  80. ; Use of trans sid may risk your users security.
  81. ; Use this option with caution.
  82. ; - User may send URL contains active session ID
  83. ;   to other person via. email/irc/etc.
  84. ; - URL that contains active session ID may be stored
  85. ;   in publically accessible computer.
  86. ; - User may access your site with the same session ID
  87. ;   always using URL stored in browser's history or bookmarks.
  88. session.use_trans_sid = 0
  89.  
  90. ; The URL rewriter will look for URLs in a defined set of HTML tags.
  91. ; form/fieldset are special; if you include them here, the rewriter will
  92. ; add a hidden <input> field with the info which is otherwise appended
  93. ; to URLs.  If you want XHTML conformity, remove the form entry.
  94. ; Note that all valid entries require a "=", even if no value follows.
  95. url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
  96.  
Thanks for any help that you can provide.

Mike
Aug 8 '07 #1
Share this Question
Share on Google+
3 Replies


epots9
Expert 100+
P: 1,351
Hi,

I am attempting to use php session variables on a server which is running Red Hat Linux, but the variables don't seem to be getting passed between pages. I have tried the same exact test script on my third party webhost, and it works just fine. Does anyone know of anything that needs to be changed in a default Red Hat php setup?

This is the test script that I am using:
http://php.about.com/od/advancedphp/ss/php_sessions.htm

This is what I was given as the default setup for redhat:
<snip>
Thanks for any help that you can provide.

Mike
Hi mikeboston welcome to TSDN,

can we see the php code that u are using to set the sessions and the php code where u are trying to access them.

thank you
Aug 8 '07 #2

P: 2
Hi mikeboston welcome to TSDN,

can we see the php code that u are using to set the sessions and the php code where u are trying to access them.

thank you
Hi Epots, yes, the code is the exact code that you find at that link above. The link goes to a php session variables tutorial. Here is the script in action, working just fine: http://gurry.com/session

Thanks,
Mike

page 1:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start(); 
  3.  
  4. // makes an array 
  5. $colors=array('red', 'yellow', 'blue'); 
  6. // adds it to our session 
  7. $_SESSION['color']=$colors; 
  8. $_SESSION['size']='small'; 
  9. $_SESSION['shape']='round'; 
  10. print "Done";
  11. ?>
  12.  
  13.  
  14. page 2:
  15. <?php 
  16. session_start(); 
  17. Print_r ($_SESSION);
  18. echo "<p>";
  19.  
  20. //echo a single entry from the array
  21. echo $_SESSION['color'][2];
  22. ?>
  23.  
Aug 8 '07 #3

Atli
Expert 5K+
P: 5,058
This is most likely a problem with your PHP configuration.

Try adding this to the top of your page, after the session_start() function call:
Expand|Select|Wrap|Line Numbers
  1. echo "<p>". session_id() ."</p>";
  2.  
This will print the session id, which should stay the same throughout the session.
Aug 8 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.