Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Ben Edwards

Dont use sessions, they are a little flaky anyway.  Use a mixture of holding
data in database and passing sid/userid/hash around on the URL.  You wont regret
it.

I have written here several times on this subject and in the end those who

have gratiously helped me have ended up just telling me they have no clue
why it doesn't work. It HAS to be my server setup but I don't know what it

could be.

Sessions just don't work on my machine...

The heart of the problem is the session_start() function.

The first time you start a session with this function it creates a new
session, that's fine.

The problem happens when it's run and no matter if the SSID is in a cookie

or passed via a form, it will still create a new session, every single time.

It will not pickup the old session.

Here is the app I setup to demonstrate the problem:

http://fromtheduke.com/session/

The first page initiates the session, the variable is posted to the next
page, the next page should retrieve the session and display the first two
variables which were registered in the session, then display the third var.


You'll see the third var showsup, the first two don't.  The session ID may

or may not remain the same. If you manually remove the index2.php file and

reload the first page, the SSID will have changed.

Source of the files:
index.php:
?

session_start();

session_register(var1);
session_register(var2);

$var1 = My var 1;
$var2 = My var 2;

?HTML
HEAD
TITLESession Page 1/TITLE
/HEAD

BODY BGCOLOR=#FF

PHPSESSID: ? echo $PHPSESSID; ?BR
Var1: ? echo $var1; ?BR
Var2: ? echo $var2; ?BR

FORM ACTION=index2.php METHOD=POST
VAR 3: INPUT TYPE=TEXT VALUE=My Var 3 NAME=myvar3 INPUT TYPE=SUBMIT

VALUE=goBR
/FORM

/BODY
/HTML
--

Source of index2.php:
?

session_start();// start session
session_register(var3);  // register var 3 session variable

$var3 = $myvar3;
?HTML
HEAD
TITLESession Page 2/TITLE
/HEAD

BODY BGCOLOR=#FF

PHPSESSID: ? echo $PHPSESSID; ?BR
Var1: ? echo $var1; ?BR
Var2: ? echo $var2; ?BR
VAR3: ? echo $var3; ?BR

/BODY
/HTML
--

I have tried session_name() to force the session ID. I was told though this

function doesn't set the SSID. It gives the SSID a name or something.

I have been told this is all setup correctly, yet, you can see it doesn't
work.

The permissions on my /tmp directory look like this:

drwxrwxrwt  /tmp

Does this have anything to do with this? I don't know much about the
permissions part of things.

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




--
[EMAIL PROTECTED]+44 (0)7970 269 522
http://www.subvertise.org   -- Altering the Corporate Image
http://www.criticaldistribution.org -- Buy Alternative Video Online
http://www.videonetwork.org -- Community/Radical Video
http://www.spamcop.net/ -- Killing SPAM feels good!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Jay Paulson

I had the exact same problem.. don't know if you had this advice yet or not
but what I did is when I started a session I would grab the session id for
that session and put it in a variable and then just pass that session id
everywhere I went.. turn on the trans_id or add the session id to the end of
every link so it gets pass throughout all the links/forms you have on the
site.

start_session();
$SID = session_id();

That's what I do and then I just pass the $SID on all the links and forms
and it works for me.

Hope that helps or is at least something new for you to try.
jay

- Original Message -
From: Thomas Deliduka [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Monday, September 24, 2001 10:56 AM
Subject: [PHP] Sessions just don't work on my machine. (Trying this again)


 I have written here several times on this subject and in the end those who
 have gratiously helped me have ended up just telling me they have no clue
 why it doesn't work. It HAS to be my server setup but I don't know what it
 could be.

 Sessions just don't work on my machine...

 The heart of the problem is the session_start() function.

 The first time you start a session with this function it creates a new
 session, that's fine.

 The problem happens when it's run and no matter if the SSID is in a cookie
 or passed via a form, it will still create a new session, every single
time.
 It will not pickup the old session.

 Here is the app I setup to demonstrate the problem:

 http://fromtheduke.com/session/

 The first page initiates the session, the variable is posted to the next
 page, the next page should retrieve the session and display the first two
 variables which were registered in the session, then display the third
var.

 You'll see the third var showsup, the first two don't.  The session ID may
 or may not remain the same. If you manually remove the index2.php file and
 reload the first page, the SSID will have changed.

 Source of the files:
 index.php:
 ?

 session_start();

 session_register(var1);
 session_register(var2);

 $var1 = My var 1;
 $var2 = My var 2;

 ?HTML
 HEAD
 TITLESession Page 1/TITLE
 /HEAD

 BODY BGCOLOR=#FF

 PHPSESSID: ? echo $PHPSESSID; ?BR
 Var1: ? echo $var1; ?BR
 Var2: ? echo $var2; ?BR

 FORM ACTION=index2.php METHOD=POST
 VAR 3: INPUT TYPE=TEXT VALUE=My Var 3 NAME=myvar3 INPUT TYPE=SUBMIT
 VALUE=goBR
 /FORM

 /BODY
 /HTML
 --

 Source of index2.php:
 ?

 session_start();// start session
 session_register(var3);  // register var 3 session variable

 $var3 = $myvar3;
 ?HTML
 HEAD
 TITLESession Page 2/TITLE
 /HEAD

 BODY BGCOLOR=#FF

 PHPSESSID: ? echo $PHPSESSID; ?BR
 Var1: ? echo $var1; ?BR
 Var2: ? echo $var2; ?BR
 VAR3: ? echo $var3; ?BR

 /BODY
 /HTML
 --

 I have tried session_name() to force the session ID. I was told though
this
 function doesn't set the SSID. It gives the SSID a name or something.

 I have been told this is all setup correctly, yet, you can see it doesn't
 work.

 The permissions on my /tmp directory look like this:

 drwxrwxrwt  /tmp

 Does this have anything to do with this? I don't know much about the
 permissions part of things.

 --

 Thomas Deliduka
 IT Manager
  -
 New Eve Media
 The Solution To Your Internet Angst
 http://www.neweve.com/



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Tamas Arpad

On Monday 24 September 2001 18:20, Thomas Deliduka wrote:
 On 9/24/2001 12:22 PM this was written:
  Try to use constant SID, maybe that will work, and it is more
  likely that it will work on other intallations with other session
  variable names.

 I just tried using SID in my index.php and there is nothing that
 displays. Hmmm.
The try this link almost works for me. You just forget the ? sign 
before the SID.
Arpi


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Johnson, Kirk

Perhaps you could post the [Session] section of your php.ini file. It
appears that session.cookie_lifetime is not set to 0, which is what you want
for a session cookie. Perhaps we can find another setting that needs a
change.

Kirk

 Sessions just don't work on my machine...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 12:28 PM this was written:

 Perhaps you could post the [Session] section of your php.ini file. It
 appears that session.cookie_lifetime is not set to 0, which is what you want
 for a session cookie. Perhaps we can find another setting that needs a
 change.

My php.ini:

[Session]
session.save_handler  = files
session.save_path = /tmp

session.use_cookies   = 1
session.name  = PHPSESSID

session.auto_start= 0
session.cookie_lifetime   = 3600

session.cookie_path   = /
session.cookie_domain =
session.serialize_handler = php

session.gc_probability= 1

session.gc_maxlifetime= 1440

session.referer_check = 0

session.entropy_length= 0
session.entropy_file  =
; session.entropy_length= 16
; session.entropy_file  = /dev/urandom
session.cache_limiter = nocache

session.cache_expire  = 180


-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Johnson, Kirk

 After reloading IE on the PC now the SID constant doesn't 
 echo anything at
 all.

SID is always defined on the first page request. It is only defined on later
page requests if cookies are disabled in the browser. 

Kirk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 12:32 PM this was written:

 After reloading IE on the PC now the SID constant doesn't
 echo anything at
 all.
 
 SID is always defined on the first page request. It is only defined on later
 page requests if cookies are disabled in the browser.

So, I shouldn't use that if I'm depending on SID to display on pages to pass
the session ID.  Or what, disable cookie support in my php.ini?

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 12:39 PM this was written:

 Try these changes:
 
 session.cookie_lifetime   = 0
 session.use_trans_sid = 1
 
 Also, what version of PHP are you using?

PHP: 4.0.6

In the past I had problems with trans_sid with urls that already had
querystrings being passed. They would mess up the querystrings, has that
been fixed?

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 12:39 PM this was written:

 Try these changes:
 
 session.cookie_lifetime   = 0
 session.use_trans_sid = 1
 

I see no changes to my problems.
-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

I'm finding my script on www.fromtheduke.com/session/ still doesn't work
even with the ?=SID? in the link or passing it along in the form.

On 9/24/2001 12:49 PM this was written:

 On Monday 24 September 2001 18:39, Thomas Deliduka wrote:
 On 9/24/2001 12:32 PM this was written:
 After reloading IE on the PC now the SID constant doesn't
 echo anything at
 all.
 
 SID is always defined on the first page request. It is only
 defined on later page requests if cookies are disabled in the
 browser.
 
 So, I shouldn't use that if I'm depending on SID to display on
 pages to pass the session ID.  Or what, disable cookie support in
 my php.ini?
 No, SID constant is especially usefull when you don't know if the
 user accepts cookies or not. SID will have a real value (e.g.
 PHPSESSID=lk123s) when you should add it to the url, and will
 have an empty value when you don't need to deal with it (because it's
 been stored in cookie).

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 1:05 PM this was written:

 On Monday 24 September 2001 18:51, Thomas Deliduka wrote:
 I'm finding my script on www.fromtheduke.com/session/ still doesn't
 work even with the ?=SID? in the link or passing it along in the
 form.
 Please send us your latest code again, then we can help you, not just
 guessing what you've might done.

Latest code:
index.php:
?
error_reporting(E_ALL);
session_start();

session_register(var1);
session_register(var2);

$var1 = My var 1;
$var2 = My var 2;

?HTML
HEAD
TITLESession Page 1/TITLE
/HEAD

BODY BGCOLOR=#FF

PHPSESSID: ? echo $PHPSESSID; ?BR
Var1: ? echo $var1; ?BR
Var2: ? echo $var2; ?BR

FORM ACTION=index2.php METHOD=POST
Passing sessid: INPUT TYPE=TEXT VALUE=? echo $PHPSESSID; ? SIZE=40
NAME=PHPSESSIDBR
VAR 3: INPUT TYPE=TEXT VALUE=My Var 3 NAME=myvar3 INPUT TYPE=SUBMIT
VALUE=goBR
/FORM
BR
A HREF=index2.php??=SID?Try this link/A
/BODY
/HTML


index2.php:
?
error_reporting(E_ALL);
session_start();// start session
session_register(var3);  // register var 3 session variable

$var3 = $myvar3;
?HTML
HEAD
TITLESession Page 2/TITLE
/HEAD

BODY BGCOLOR=#FF

PHPSESSID: ? echo $PHPSESSID; ?BR
Var1: ? echo $var1; ?BR
Var2: ? echo $var2; ?BR
VAR3: ? echo $var3; ?BR

/BODY
/HTML
-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 1:15 PM this was written:

 OK, now the session ID is getting passed like it should. Now for the two
 missing variables. Try moving the two assignment statements ahead of the two
 session_register() calls - assign, then register. I have never seen this
 make a difference, but the pros on this list say that is the way it needs to
 be done.

Done, I switched the four lines around.
?
error_reporting(E_ALL);
session_start();

$var1 = My var 1;
$var2 = My var 2;

session_register(var1);
session_register(var2);

?HTML
HEAD
TITLESession Page 1/TITLE
/HEAD

BODY BGCOLOR=#FF

PHPSESSID: ? echo $PHPSESSID; ?BR
Var1: ? echo $var1; ?BR
Var2: ? echo $var2; ?BR

FORM ACTION=index2.php METHOD=POST
Passing sessid: INPUT TYPE=TEXT VALUE=? echo $PHPSESSID; ? SIZE=40
NAME=PHPSESSIDBR
VAR 3: INPUT TYPE=TEXT VALUE=My Var 3 NAME=myvar3 INPUT TYPE=SUBMIT
VALUE=goBR
/FORM
BR
A HREF=index2.php??=SID?Try this link/A
/BODY
/HTML

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

On 9/24/2001 1:18 PM this was written:

 OK, now the session ID is getting passed like it should. Now for the two
 missing variables. Try moving the two assignment statements ahead of the two
 session_register() calls - assign, then register. I have never seen this
 make a difference, but the pros on this list say that is the way it needs to
 be done.
 
 Done, I switched the four lines around.

Same result.
-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

Thank you everyone for your continued help with this. It's still not fixed
but I have to leave to a dr. appt. I hope that most--If not all--of you are
on when I get back.

I just wanted to alert you as to why I wouldn't be responding to your
questions/messages.

Here is the last information I sent Tamas:

I find as exepcted, it's creating a new PHPSESSID every time I post to the
index2.php

As I mentioned in the first e-mail, it ust creates a new session. But this
is something I find interesting.

I start the session for the first time, it regsiters var1 and var2.

Then I post to the next page, the PHPSESSID values are posted perfectly fine
but on the server a new session with a different vale is created with var3
in it.

Then I will reload the first page again by erasing index2.php and hitting
enter and it will display a new sess id number and show the first page, as
normal but that sessid number is equal t the new session created on the
server and the value of it is:

var3; var1; var2

This is stranger than strange.

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

Yeah, I think it's my server setup, or something I have going on on my
server because others have said that it works fine for them but not on my
machine.

I'm running red hat linux 6.1 apache+mod_ssl 1.3.20

On 9/24/2001 2:08 PM this was written:

 
 Then I will reload the first page again by erasing index2.php and
 hitting enter and it will display a new sess id number and show the
 first page, as normal but that sessid number is equal t the new
 session created on the server and the value of it is:
 
 var3; var1; var2
 
 This is stranger than strange.
 This isn't so strange. The session id is stored in a cookie.
 
 But.. I turned off cookies (debuging can be done much easier), and
 played a little.
 I found that the session is created properly on the first page and
 the 2 variables are registered too.
 But on the second page they aren't set on the first view (that's
 stange!).
 If I reload the page (of course the same sid is in the url), the 2
 variables this time are set, with their value that were given on the
 first page (that's why I told above they were registered, and their
 values are stored properly, so it's not a problem of rights, session
 save paths, etc..)
 So that's what I've found, but I have to go home now sorry.
 On the other hand the 2 source file you've sent me worked fine on my
 computer, without any problems (and warnings).

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sessions just don't work on my machine. (Trying this again)

2001-09-24 Thread Thomas Deliduka

I just tried this here below. Before trying this I changed any called to
$PHPSESSID to session_id().

I turned off cookies
Loaded the page... Created session id and file:
sess_44074d3a54862b480c3407c9eb373f77
Contents: var1|s:8:My var 1;var2|s:8:My var 2;

I submitted the form:
PHPsessionid shows up as: 2f633e17c6752342d0c1e7e6191b4112
New file with same name contents: var3|s:8:My Var 3;

I removed index2.php and went back to the first file.
PHP SessID shows up as 68b482365d9086068edfa3e35d8dd41d
Corresponding file with contents: var1|s:8:My var 1;var2|s:8:My var 2;

This is different then what I previously said.

But it's clear to me that each time session_start() is called, it doesn't
open the existing session rather it creates a new one.

When I click the 'try this link' instead when starting over. It still
creates a new session ID on the server.


On 9/24/2001 1:31 PM this was written:

 OK, do you have access to your /tmp directory? If so, close your browser,
 then open it and request your index page. Now sort the files in /tmp by
 creation time, to find the newly created session file. Look at its contents,
 and see if the 2 variables have values assigned to them in the file. Do this
 before you click submit on index.
 
 BTW, I don't think $PHPSESSID is ever defined on the first request. Instead,
 you can do this to see the new session ID on the first page. That will also
 help you find the correct session file to inspect.
 
 echo session id is  . session_id() . br\n;

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]