$_SESSION and header("Location:")

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

olog-hai wrote:My cookie or file that keep my session is always deleted when I refresh my page.
The client-side cookie, i.e. no session id is sent to the server and therefore a new session is created?
Or the server-side file that contains the session data?
User avatar
olog-hai
Forum Commoner
Posts: 34
Joined: Thu May 31, 2007 8:47 am
Location: Québec city, QC, Canada

Post by olog-hai »

My session cookie save path is c:\windows\temp

I deleted all file manually

I go on my home page

a file like sess_kf8djfa8djfa8jasfa8sdfsad8afj8a is created

I logged on my home page.
and the file sess_kf8djfa8djfa8jasfa8sdfsad8afj8a is automatically deleted.

so when I refreshed my page the session isn't reloaded cause the file do not exist anymore.

____________________

I created an empty object and serialize it on my home page, I opened the kind of file sess_kf8djfa8djfa8jasfa8sdfsad8afj8a and the content was not plain text but the whole content is □. If I print_r() my object before serialize it, I see plain text of my whole object. is it normal to not see plain text on that sess_kf8djfa8djfa8jasfa8sdfsad8afj8a file ?

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sounds like your garbage collection routine is running a bit too quickly, possibly... or you have session destruction logic that's being run.
User avatar
olog-hai
Forum Commoner
Posts: 34
Joined: Thu May 31, 2007 8:47 am
Location: Québec city, QC, Canada

Post by olog-hai »

; 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 = 100


this is my config file.

If I change the 1 to 0 what is the impact ?

To answer your second think, I dont implement __destruct() on any of my classes.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

__destruct() isn't the only thing involved in session destruction however. There can also be header(), setcookie(), session_destroy(), your computer's own settings, even browser settings.
Post Reply