PDA

View Full Version : Cookies (and Sessions), OH MY?!


Halide
08-28-2002, 03:02 PM
I had these down. Or so I thought.

For some reason my cookies and sessions won't work on my current host, but they worked on my previous host. Does anyone have any idea how or why this could happen? Maybe a HTTP header problem since the host I'm on now uses a folder (http://scripts.tribes-universe.com/halide) and my old host didn't (http://halide.tribes2.org). I am only specifying the cookie name, value, and expiration date, not the other "optional" parameters.

Grizzly
08-28-2002, 03:51 PM
Use this little script to check the session settings on each of your servers.


<?php // list whatever INI settings you want displayed...
$iniSettings = array(
0 => "session.save_handler",
1 => "session.save_path",
2 => "session.use_cookies",
3 => "session.auto_start",
4 => "session.cookie_lifetime",
5 => "session.cookie_path",
6 => "session.cookie_domain",
7 => "session.serialize_handler",
8 => "session.gc_probability",
9 => "session.gc_maxlifetime",
10 => "session.entropy_length",
11 => "session.entropy_file",
12 => "session.entropy_length",
13 => "session.cache_limiter",
14 => "session.cache_expire",
15 => "session.use_trans_sid");
?>
<html><head></head><body>
<h2>PHP ini settings</h2>
<table width="550" cellpadding="3" cellspacing="0" border="1" bordercolor="navy">
<?php for($i=0;$i<sizeof($iniSettings);$i++){ ?>
<tr>
<td width="120"><?=$iniSettings[$i]?></td>
<td><?=ini_get($iniSettings[$i])?></td>
</tr>
<?php } ?>
</table>
</body>
</html>


Particularly pay attention to the values for "session.use_cookies", and "session.save_handler". I've heard that if session.save_handler is set to "user", than you'll have some trouble on your hands.

It could be that your server admin disabled sessions in the PHP settings. Exactly what errors are you getting?

Halide
08-28-2002, 05:27 PM
I'm not getting errors, just no cookies are being sent by the client, AFAIK, and I have no idea why!

Grizzly
08-28-2002, 05:32 PM
Did you use the script I posted above? What are the server's session settings?

Halide
08-28-2002, 05:55 PM
GREAT! now the ftp for this SERVER is down.

I'll try it soon

imported_Gryphon
08-28-2002, 06:32 PM
Shoulda stayed at t2org dummy.

Halide
08-28-2002, 06:58 PM
man the ftp is still down
...

Halide
08-28-2002, 07:01 PM
here's the results on MY php setup:

PHP ini settings
session.save_handler files
session.save_path C:\PHP\sessiondata
session.use_cookies 1
session.auto_start 0
session.cookie_lifetime 0
session.cookie_path /
session.cookie_domain
session.serialize_handler php
session.gc_probability 1
session.gc_maxlifetime 1440
session.entropy_length 0
session.entropy_file
session.entropy_length 0
session.cache_limiter nocache
session.cache_expire 180
session.use_trans_sid 1

Halide
08-29-2002, 12:58 AM
I just figured out their settings are fine (same as mine).

The problem is the set-cookie header isn't being sent with the pages for some reason. I just figured this part out. SOMEONE HELP! :wtf:

roninblade
08-29-2002, 04:18 AM
how are you setting your cookies? post that code block please. btw, have you tried testing with different browsers? chances are your script is only having problems setting cookies in IE. ;)

Halide
08-29-2002, 08:09 AM
Nope, it's completely a server-side problem, because there is no Set-Cookie header. It works on other servers and it works in any browser... i even tried netscape :p

imported_Gryphon
08-29-2002, 12:08 PM
Yeah the cookies all worked great until he changed hosts, bad Halide, told ya not to move :D

Halide
08-30-2002, 11:17 PM
this is so ghey.. why won't it accept cookies from my domain

imported_Gryphon
08-30-2002, 11:18 PM
:D

roninblade
08-30-2002, 11:42 PM
can you just work around it? how about passing SID in the url so your sessions wont depend on cookies to pass your variables.

Halide
08-31-2002, 12:06 AM
nope, because I use cookies for my forum, but sessions are broke as well... i have the php trans sid or whatever

roninblade
08-31-2002, 01:23 AM
so let me get this straight, both sessions and cookies are not setting? (i thought it was just sessions and the session cookies)

Halide
08-31-2002, 01:41 AM
sessions don't save between page loads, and cookies don't set either (i.e. I don't even see a cookie file, but I know the set-cookie header is there)

imported_Gryphon
08-31-2002, 01:43 AM
Did you see my post on you forum Hal? The Poll appears to be saving the cookie.

Halide
08-31-2002, 01:48 AM
*cough*

did you see my reply :)

imported_Gryphon
08-31-2002, 01:54 AM
Hmmm the TU forums save my cookie :/

Halide
08-31-2002, 02:11 AM
?