Page 1 of 1
sessions problem
Posted: Sat Feb 07, 2004 12:07 am
by derek233
I am using latest verion of php on Win XP pro.
I am trying to get sessions to work on my local apache server (latest version). I have register_globals set to off . Further, the below test code works on my other server over the net. What could be wrong???
here are the 2 simple test pages:
<?php
session_start();
$HTTP_SESSION_VARS['sess_var'] = "Hello world!";
echo 'The content of $HTTP_SESSION_VARS[''sess_var''] is '
.$HTTP_SESSION_VARS['sess_var'].'<br />';
?>
<a href="page2.php">Next page</a>
///////page2.php
<?php
session_start();
echo 'The content of $HTTP_SESSION_VARS[''sess_var''] is '
.$HTTP_SESSION_VARS['sess_var'].'<br />';
unset($HTTP_SESSION_VARS['sess_var']);
?>
Posted: Sat Feb 07, 2004 6:56 am
by qads
dont use $HTTP_SESSION_VARS['var'];, use $_SESSION['var'];
Posted: Sat Feb 07, 2004 10:45 am
by ol4pr0
You could always have youre php.ini set to
SESSION_AUTO_START=1
or something like that... that way it will automatcly start its session.
Posted: Sat Feb 07, 2004 12:33 pm
by derek233
I changed my variables to use $_SESSION['var']; . This did not help. Also I set session_auto_start =1 . This did not help.
THis must be a configuration issue within the php.ini file. I just do not seem to be able to find the problem. Here is my section of the php.ini file pertaining to sessions:
//////////////////////////////////////////////////////////////////
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = /
; Whether to use cookies.
session.use_cookies = 1
; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1
; Name of the session (used as cookie name).
session.name = PHPSESSID
; Initialize session on request startup.
session.auto_start = 1
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
; The path for which the cookie is valid.
session.cookie_path = /
; The domain for which the cookie is valid.
session.cookie_domain = none
; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.
session.gc_probability = 1
session.gc_divisor = 1000
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning seperately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.
session.bug_compat_42 = 0
session.bug_compat_warn = 1
; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =
; How many bytes to read from the file.
session.entropy_length = 0
; Specified here to create the session id.
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
; Set to {nocache,private,public,} to determine HTTP caching aspects.
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache
; Document expires after n minutes.
session.cache_expire = 180
; trans sid support is disabled by default.
; Use of trans sid may risk your users security.
; Use this option with caution.
; - User may send URL contains active session ID
; to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
; in publically accessible computer.
; - User may access your site with the same session ID
; always using URL stored in browser's history or bookmarks.
session.use_trans_sid = 1
; The URL rewriter will look for URLs in a defined set of HTML tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs. If you want XHTML conformity, remove the form entry.
; Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mssql.max_persistent = -1
; Maximum number of links (persistent+non persistent). -1 means no limit.
mssql.max_links = -1
; Minimum error severity to display.
mssql.min_error_severity = 10
; Minimum message severity to display.
mssql.min_message_severity = 10
; Compatability mode with old versions of PHP 3.0.
mssql.compatability_mode = Off
; Connect timeout
;mssql.connect_timeout = 5
; Query timeout
;mssql.timeout = 60
; Valid range 0 - 2147483647. Default = 4096.
;mssql.textlimit = 4096
; Valid range 0 - 2147483647. Default = 4096.
;mssql.textsize = 4096
; Limits the number of records in each batch. 0 = all records in one batch.
;mssql.batchsize = 0
; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On
; Use NT authentication when connecting to the server
mssql.secure_connection = Off
; Specify max number of processes. Default = 25
;mssql.max_procs = 25
Posted: Sat Feb 07, 2004 12:42 pm
by ol4pr0
NOthing wrong with youre php.ini.....
Did you have a look @ youre php root dir? /php(?4?)/sessions/
Posted: Sat Feb 07, 2004 6:45 pm
by derek233
Oh, this could be a problem. I do not seem to have a sessions folder. My php application is loaded C:\PHP . Within this folder I have the following folders:
cli
dlls
openssl
pdf-related
PEAR
sapi
Does this seem correct?
Posted: Sat Feb 07, 2004 6:55 pm
by derek233
OH SWEET! I figured this out.
Based on the last suggestion, I looked at php.ini file again. Specifically, I looked at this code:
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = /
I changed this last line of code to:
session.save_path = C:\PHP
Wah-freakin-La it works! I can even witness the session file appear at C:\PHP. So, cool. Thank you so much, for all your help and suggestions.
Posted: Sun Feb 08, 2004 7:28 am
by qads
nice, glad you sorted it out, may wanna make anothe folder for sessions though, no harm in jaming them in c:/php but c:php:session might be better cos latter when you want o write your own (you wanna?) session handlers, it will better

.
Posted: Mon Feb 23, 2004 2:56 pm
by Magosoft
Ok, every I have done everything in the thread, but.
I'm developing a page with Apache 1.3.X and php-4.3.4,
under Windows 2000 professional.
In my php.ini file I had set the session_path="C:\php\sessions"
when I start the session with:
<?php
session_start();
$_SESSION['myvar]='Some string';
echo '<a href="test.php">Test</a>';
?>
This creates a file with the name:
sess_56#######.....etc.
When I edit it is says:
myvar|s:11:"Some string"
However, when I hit the Test link on my page
the value does not exists in the new page, and
it creates me a new session file in the session folder.
The code for the test.php file is:
<?php
session_start();
echo $_SESSION['myvar'];
?>
Any help will be appreciated.
MAGO