Page 1 of 1

Session Problem (..)

Posted: Sun Nov 24, 2002 10:30 am
by mortadelle
Here is my problem :

I've build 3 pages in which i try to test that session are being passed to pages :

The point is that it works fine the first time, but on page 2 if i double check the page (with the link) it fails ... I dont understand why ????!!!

page 0:

Code: Select all

session_start();
if (!empty($_SESSION)) 
{
    session_destroy();
}
<a href="page1.php">page1</a>


page1

Code: Select all

session_start();
//$HTTP_SESSION_VARS&#1111;'test'] = 1; 
// i've test $_SESSION&#1111;'test'] = 1; too but it seems to work worst
$test=1;
session_register('test');
echo "&lt;!--";
    print_r($_SESSION);
    echo "&lt;br&gt;&lt;br&gt;";
    print_r($HTTP_SESSION_VARS);
echo "--&gt;";
<a href='page2.php?PHPSESSID=<?=$PHPSESSID?>'>Page 2</a>

Page 2

Code: Select all

session_start();
//if (!empty($_SESSION&#1111;'test'])) 
if (!empty($HTTP_SESSION_VARS&#1111;'test'])) 
{
    echo 'it worked!';
    print_r($_SESSION);
    echo "&lt;br&gt;&lt;br&gt;";
    print_r($HTTP_SESSION_VARS);

} else {
    echo 'it did not work ';

    echo "&lt;!--";
    print_r($_SESSION);
    echo "&lt;br&gt;&lt;br&gt;";
    print_r($HTTP_SESSION_VARS);
    echo "--&gt;";
}
<a href="page2.php?PHPSESSID=<?=$PHPSESSID?>">page 2 again</a>

I use php 4.2.3 and :

register_globals ON

session.auto_start ON
session.cache_expire 180
session.cache_limiter nocache
session.cookie_lifetime 0
session.cookie_secure Off
session.gc_maxlifetime 1440
session.gc_probability 1
session.referer_check no value
session.use_cookies On
session.use_trans_sid 0

Posted: Mon Nov 25, 2002 3:14 am
by twigletmac
Using $_SESSION shouldn't work worst, unless you have session_register() and are using $_SESSION and/or $HTTP_SESSION_VARS at the same time. Does just using the following code work:

page1.php

Code: Select all

&lt;?php 
session_start(); 
if (!empty($_SESSION&#1111;'test'])) { 
    unset($_SESSION&#1111;'test']);
    session_destroy(); 
    echo '&lt;pre&gt;Session Destroyed ';
    print_r($_SESSION); 
    echo '&lt;/pre&gt;'; 
} 

$_SESSION&#1111;'test'] = 1; 
echo '&lt;pre&gt;New Session ';

print_r($_SESSION); 
echo '&lt;/pre&gt;'; 
echo '&lt;a href="page2.php"&gt;Page 2&lt;/a&gt;'; 
?&gt;
page2.php

Code: Select all

&lt;?php
session_start();
echo '&lt;pre&gt;$_SESSION information ';
print_r($_SESSION);
echo '&lt;/pre&gt;';
?&gt;
Mac

Posted: Mon Nov 25, 2002 6:45 am
by mortadelle
thx for your response.


Unfortunatly I've tried what you indicates but if fails :

on page 2 i have the error :

$_SESSION information
Warning: Undefined variable: _SESSION in e:\sitenplus1\2003\admin\page2.php


and on page1. i've got the $_SESSION array initialized but .. i think it is only the array var that is initialiazed but not the SESSION var .... ???

Posted: Mon Nov 25, 2002 6:46 am
by twigletmac
What does the code you are working with look like?

Mac

Posted: Mon Nov 25, 2002 9:45 am
by mortadelle
Page 1 :

<?php
session_start();
if (!empty($_SESSION['test'])) {
unset($_SESSION['test']);
session_destroy();
echo '<pre>Session Destroyed ';
print_r($_SESSION);
echo '</pre>';
}

$_SESSION['test'] = 1;
echo '<pre>New Session ';

print_r($_SESSION);
echo "<br>";
print_r($HTTP_SESSION_VARS);
echo '</pre>';
echo '<a href="page2.php?phpsessid='.$PHPSESSID.'">Page 2</a>';
?>



generates :

<pre>New Session Array
(
[test] => 1
)
<br>Array
(
[test] => 1
)
</pre><a href="page2.php?phpsessid=1144622cdd80c02676c9d4c6655f2482">Page 2</a>

Page 2 :

<?php
session_start();
echo '<pre>$_SESSION information ';
print_r($_SESSION);
echo "<br>";
print_r($HTTP_SESSION_VARS);
echo '</pre>';
?>

generates :

<pre>$_SESSION information <br></pre>

NB : there is no visible errors because error_report is set on 81 ... and i can not modify it (i have no access to this php.ini)

Moreover i have no HTML tags (<html> <body> etc.) but i think this changes nothing ?

Posted: Mon Nov 25, 2002 9:52 am
by twigletmac
I haven't properly had a look at the rest of the code yet but if you want to see the errors try putting the following in your script:

Code: Select all

ini_set('display_errors', 1);
If you haven't got access to the php.ini there are a bunch of values that you can alter for your script using ini_set().

Mac

Posted: Mon Nov 25, 2002 10:07 am
by mortadelle
i add the code (i think i tried it before ..) but nothing happen ...no error nada ...

The "funny" 8O thing is that the first time i've got nothing :

<pre>$_SESSION information <br></pre>

and if i refresh 1 time i've got :

<pre>$_SESSION information Array
(
[test] => 1
)
<br>Array
(
[test] => 1
)
</pre>

It works !! then i refresh couples of times : still works and one more time and tada :

it fails i go back to :

<pre>$_SESSION information <br></pre>

I a m really gone MAD !! ...



here is an extract of this phpinfo (i've looked at it but it seems ok for me ? do you find something weird ?)


PHP Version 4.2.3

System
Windows NT 5.0 build 2195
Build Date
Sep 6 2002 10:38:51
Server API
ISAPI
Virtual Directory Support
enabled
Configuration File (php.ini) Path
C:\WINNT\php.ini
Debug Build
no
Thread Safety
enabled

This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.2.0, Copyright (c) 1998-2002 Zend Technologies


PHP 4 Credits

Configuration
PHP Core
Directive
Local Value
Master Value
allow_call_time_pass_reference
On
allow_url_fopen
1
always_populate_raw_post_data
0
arg_separator.input
&
arg_separator.output
&
asp_tags
Off
auto_append_file
no value
auto_prepend_file
no value
browscap
no value
default_charset
no value
default_mimetype
text/html
define_syslog_variables
Off
disable_functions
no value
display_errors
Off
display_startup_errors
Off
doc_root
no value
enable_dl
On
error_append_string
no value
error_log
c:\php\php_error.log
error_prepend_string
no value
error_reporting
81
81
expose_php
On
extension_dir
c:\php\extensions
file_uploads
1
gpc_order
GPC
highlight.bg
#FFFFFF
highlight.comment
#FF8000
highlight.default
#0000BB
highlight.html
#000000
highlight.keyword
#007700
highlight.string
#DD0000
html_errors
On
ignore_user_abort
Off
implicit_flush
Off
include_path
.;c:\.;c:\php\pear
log_errors
On
magic_quotes_gpc
On
magic_quotes_runtime
Off
magic_quotes_sybase
Off
max_execution_time
20
open_basedir
no value
output_buffering
no value
output_handler
no value
post_max_size
8M
precision
12
register_argc_argv
On
register_globals
On
safe_mode
Off
safe_mode_exec_dir
no value
safe_mode_gid
Off
safe_mode_include_dir
no value
sendmail_from
me@localhost.com
sendmail_path
no value
short_open_tag
On
sql.safe_mode
Off
track_errors
Off
unserialize_callback_func
no value
upload_max_filesize
2M
upload_tmp_dir
no value
user_dir
no value
variables_order
EGPCS
xmlrpc_error_number
0
xmlrpc_errors
Off
y2k_compliance
On

standard
Regex Library
Bundled library enabled
Dynamic Library Support
enabled
Internal Sendmail Support for Windows
enabled

Directive
Local Value
Master Value
assert.active
1
assert.bail
0
assert.callback
no value
assert.quiet_eval
0
assert.warning
1
safe_mode_allowed_env_vars
PHP_
safe_mode_protected_env_vars
LD_LIBRARY_PATH
url_rewriter.tags
a=href,area=href,frame=src,input=src,form=,fieldset=

bcmath
BCMath support
enabled

calendar
Calendar support
enabled

com
Directive
Local Value
Master Value
com.allow_dcom
Off
com.autoregister_casesensitive
On
com.autoregister_typelib
Off
com.autoregister_verbose
Off
com.typelib_file
no value

ftp
FTP support
enabled

mysql
MySQL Support
enabled
Active Persistent Links
0
Active Links
0
Client API version
3.23.39

Directive
Local Value
Master Value
mysql.allow_persistent
Off
mysql.default_host
no value
mysql.default_password
no value
mysql.default_port
no value
mysql.default_socket
no value
mysql.default_user
no value
mysql.max_links
10
mysql.max_persistent
5

odbc
ODBC Support
enabled
Active Persistent Links
0
Active Links
0
ODBC library
Win32

Directive
Local Value
Master Value
odbc.allow_persistent
Off
odbc.check_persistent
On
odbc.default_db
no value
odbc.default_pw
no value
odbc.default_user
no value
odbc.defaultbinmode
return as is
odbc.defaultlrl
return up to 4096 bytes
odbc.max_links
4
odbc.max_persistent
4

pcre
PCRE (Perl Compatible Regular Expressions) Support
enabled
PCRE Library Version
3.4 22-Aug-2000

session
Session Support
enabled

Directive
Local Value
session.auto_start
On
session.cache_expire
180
session.cache_limiter
nocache
session.cookie_domain
no value
session.cookie_lifetime
0
session.cookie_path
/
session.cookie_secure
Off
session.entropy_file
no value
session.entropy_length
0
session.gc_maxlifetime
1440
session.gc_probability
1
session.name
PHPSESSID
session.referer_check
no value
session.save_handler
files
session.save_path
c:\php\temp
session.serialize_handler
php
session.use_cookies
On
session.use_trans_sid
0

xml
XML Support
active
XML Namespace Support
active
EXPAT Version
1.95.2

wddx
WDDX Support
enabled

gd
GD Support
enabled
GD Version
1.6.2 or higher
FreeType Support
enabled
FreeType Linkage
with TTF library
JPG Support
enabled
PNG Support
enabled
WBMP Support
enabled

zlib
ZLib Support
enabled
Compiled Version
1.1.4
Linked Version
1.1.4

Directive
Local Value
zlib.output_compression
Off

ISAPI
Server Variable
Value
CONTENT_LENGTH
0
REQUEST_METHOD
GET
SERVER_PROTOCOL
HTTP/1.1
SERVER_SOFTWARE
WebSite/3.1.11
ALL_HTTP
HTTP_ACCEPT:application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
HTTP_CONNECTION:Close
HTTP_ACCEPT_LANGUAGE:fr
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTPS
OFF
CERT_FLAGS
0
CERT_KEYSIZE
0
CERT_SECRETKEYSIZE
0
HTTPS_KEYSIZE
0
HTTPS_SECRETKEYSIZE
0

Additional Modules

C:\WINNT
session.save_handler
user
¨ u ˆý; save_handler
user
¨ u X (c)8save_handler
user

PHP Variables
Variable
Value
PHP_SELF
_SERVER["ALL_HTTP"]
HTTP_ACCEPT:application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)

HTTP_CONNECTION:Close
HTTP_ACCEPT_LANGUAGE:fr
HTTP_ACCEPT_ENCODING:gzip, deflate

_SERVER["CONTENT_LENGTH"]
0
_SERVER["REQUEST_METHOD"]
GET
_SERVER["SERVER_PORT"]
80
_SERVER["SERVER_PROTOCOL"]
HTTP/1.1
_SERVER["SERVER_SOFTWARE"]
WebSite/3.1.11
_SERVER["HTTP_ACCEPT"]
application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
_SERVER["HTTP_USER_AGENT"]
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
_SERVER["HTTP_CONNECTION"]
Close
_SERVER["HTTP_ACCEPT_LANGUAGE"]
fr
_SERVER["HTTP_ACCEPT_ENCODING"]
gzip, deflate
_SERVER["DOCUMENT_ROOT"]
c
_SERVER["argv"]
Array
(
)

_SERVER["argc"]
0

_ENV["OS"]
Windows_NT
_ENV["session_save_handler_"]
user
_ENV["¨ u ˆý; save_handler_"]
user
_ENV["¨ u X (c)8save_handler_"]
user