View Full Version : Session Problem
12-23-2003, 07:20 AM
I want to start a session on a page, assign a value to a session variable then display it on another page. I've broken it down as simple as possible, and I still can't get it to work!!
$_SESSION['value'] = "Hello World";
Only value I changed in the php.ini was
session.save_path = C:\temp
Can anyone offer any advice to get me goin?
12-23-2003, 07:44 AM
I'm using version 4.3.4 and phpinfo() says Session Support is enabled.
I have no idea, based on the code you showed, i'd suspect it to work.
Maybe 'value' isn't the most sensible variablename you could choose but i doubt if that is the problem (but you soon findout ifyou change it). Is there any other code in these pages? If so,try moving these lines to the very top of your script on both pages.
12-23-2003, 09:24 PM
I look inside the session files and I can see
So this tells me its writing variable myvar, but I just can't get it to read properly. Any advice? I've tried reinstalling PHP. I dont want to use an older version of php... do I?
12-27-2003, 12:01 AM
The problem may be in how you are transitioning from page 1 to page2. Specifically, if you are using a header() call you must supply a fully qualified URL, meaning give a complete URL specification to the header such as
header( 'Location: http://www.yourdomain.com/path_to_web_page' )
I had trouble with only supplying relative paths to web pages and session variaibles.
Indeed. You can dynamically build these like:
This way, the redirect will generate a call to the webserver. I suppose i will only matter if you have cookies disabled, because the sessionID then need to be added to each request. With a serverside redirect, this iw probably not the case (not sure though)
Also, try renaming the sessionvariable --> if you have another variable called "$value", then your code will not work on certain servers. (I know i have that problem with one of my hosts)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.