Page 1 of 1
setcookie() problem
Posted: Wed Mar 16, 2005 4:58 pm
by Calimero
Background: Php 5, apache 1.xx ( the one most commonly used ), MySQL 4.0.18.
Problem - I looked at php.net and managed to set up a cookie.
Now, the problem was with the part of locking to a domain.
I saw two options - one to lock to domain, other to lock to a directory on that domain. I wanted the first one, but not the second option - tried and tried - but it never functioned as I wanted.
Can anyone just post how this should be done:
name = "Big Daddy"
value = $abc.$efg
expire = when browser closes (right away)
path = /I dont need this, this ... blasted thing
domain = mysomain.com
thanks ahead.
Posted: Wed Mar 16, 2005 5:14 pm
by Ambush Commander
Code: Select all
<?php
setcookie("Big Daddy", $abc.$efg, , '/', '.mysomain.com');
?>
The cookie set here will be accessible from all subdomains of mysomain.com in any directory.
Posted: Wed Mar 16, 2005 7:09 pm
by shiznatix
use sessions if you want it to die when the browser is closed
Posted: Wed Mar 16, 2005 7:12 pm
by Ambush Commander
Well, a lot of the time, PHP resorts to sticking a cookie as the SESSION variable, so if you were recommending that for avoiding extra cookies, it probably won't help: but in terms of versatality, yeah, $_SESSION is better.
....
Posted: Thu Mar 17, 2005 3:52 am
by Calimero
Session, hmmm ?!?
I haven't used them much - did everything with 2 frames and 10 rows of JavaScript

.
I am conserned - what I heard about them: they take up memory slots on the server machine.
So - one session how much memory it takes from my server machine ( P4 - intel (not celeron), 1mb cache, 2 GB DDR ram, 2 x 80 GB (7200) HDD, some medium graphics card, 100 mb/s network card ).
And with it - how many sessions could my machine support with running the above mentioned servers and php app's like this forum and some search engine ( not too many functions and a moderate DB )
I hope I gave enough information - and that they are clear enough.
oh yeah, and thanks for the reply.
Posted: Thu Mar 17, 2005 1:30 pm
by feyd
you can hold lots of sessions.. don't worry about them unless you are storing a LOT of information in the sessions.
...
Posted: Fri Mar 18, 2005 2:41 pm
by Calimero
Sorry to be this detailed - as I have never used sessions.
can you turn this (roughly) in the numbers:
lot of sessions,
and this especialy - lots of data ( in terms of number of variables or length of variables )
Can't create a picture in my head entirely.
Thanks in advance.
Posted: Fri Mar 18, 2005 3:18 pm
by m3mn0n
shiznatix wrote:use sessions if you want it to die when the browser is closed
Cookies can "die" when the browser is closed also.
Posted: Fri Mar 18, 2005 10:23 pm
by feyd
there is no reason to quantify the sizes involved.. you have FAR more space than most servers have for storing your session data.
Posted: Sat Mar 19, 2005 12:22 am
by shiznatix
plus sessions are easier to deal (atleast i think) since its just another array that you can easily deal with.
Sami wrote:
Cookies can "die" when the browser is closed also.
how is this done? i thought they only deleted themselves when a cetain time expired?
Posted: Sat Mar 19, 2005 12:24 am
by feyd
supply an expire time of zero. It's called a session cookie.