NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP/setcookie: Can someone work with me on c ook ies offsite here?

Chris Bielanski Cbielanski at inta.org
Fri Aug 27 13:52:39 EDT 2004


Now for that, I see a simple solution - make your $_SESSION variable a
multidimensional associative array, with credentials for each section as a
key.

$_SESSION['ABC'] = array("key1" => "value1", "key2" => "value2")
$_SESSION['XYZ'] = array("key1" => "value1", "key2" => "value2")

That way, when they log out of ABC, you only unset or blank out
$_SESSION["ABC"] and the rest of your session data persists. If you need to
pass all that stuff as a URL query sring, use
urlencode(serialize($_SESSION)) to convert the array into something that can
go into a URL.

Thanks,
Chris Bielanski
Web Programmer, 
International Trademark Association,
1133 Avenue of the Americas, 33rd Floor
New York, NY 10036
+1 (212) 642-1745, f: +1 (212) 768-7796
mailto:cbielanski at inta.org, www.inta.org  
INTA -- 125 Years of Excellence



> -----Original Message-----
> From: Phillip Powell [mailto:phillip.powell at adnet-sys.com]
> Sent: Friday, August 27, 2004 1:48 PM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] PHP/setcookie: Can someone work with me on c
> ookies offsite here?
> 
> 
> That was a very simple solution to the cookie problem, however, it 
> doesn't help solve the problem with deleting session 
> variables.  I don't 
> want to use session_destroy() as I wish to keep the session.
> 
> The session itself will be a collection object containing 
> elements from 
> several different projects on the same domain.  I want to delete the 
> session variables ONLY that pertain to the CMA project, not the XYZ 
> project or the ABC project.
> 
> This did not work:
> 
> foreach ($_SESSION as $key => $val) {
>   if (preg_match("/^${projectFolderName}_/i", $key)) 
> unset($_SESSION[$key]);
> }
> 
> This did no change to the session whatsoever.
> 
> Phil
> 
> Chris Bielanski wrote:
> 
> >Okay, disregard my last comment - glad you got it solved Phil. 
> >Personally I don't make use of cookies, so I hadn't much 
> experience with the
> >problem. If in the future I'm so required, I'll be sure to 
> watch out for
> >this :)
> >
> >
> >Thanks,
> >Chris Bielanski
> >Web Programmer, 
> >International Trademark Association,
> >1133 Avenue of the Americas, 33rd Floor
> >New York, NY 10036
> >+1 (212) 642-1745, f: +1 (212) 768-7796
> >mailto:cbielanski at inta.org, www.inta.org  
> >INTA -- 125 Years of Excellence
> >
> >
> >
> >  
> >
> >>-----Original Message-----
> >>From: Chris Bielanski [mailto:Cbielanski at inta.org]
> >>Sent: Friday, August 27, 2004 1:21 PM
> >>To: 'NYPHP Talk'
> >>Subject: RE: Re: [nycphp-talk] PHP/setcookie: Can someone work 
> >>with me on
> >>c ookies offsite here?
> >>
> >>
> >>Oh man, wouldn't that mean that IE users won't be logged 
> out until the
> >>browser restarts?
> >>
> >>Mother of *suck.*
> >>
> >>
> >>Thanks,
> >>Chris Bielanski
> >>Web Programmer, 
> >>International Trademark Association,
> >>1133 Avenue of the Americas, 33rd Floor
> >>New York, NY 10036
> >>+1 (212) 642-1745, f: +1 (212) 768-7796
> >>mailto:cbielanski at inta.org, www.inta.org  
> >>INTA -- 125 Years of Excellence
> >>
> >>
> >>
> >>    
> >>
> >>>-----Original Message-----
> >>>From: Daniel Kushner [mailto:kushner at gmail.com]
> >>>Sent: Friday, August 27, 2004 1:10 PM
> >>>To: NYPHP Talk
> >>>Subject: Re: Re: [nycphp-talk] PHP/setcookie: Can someone work 
> >>>with me on
> >>>cookies offsite here?
> >>>
> >>>
> >>>This is how IE handles cookies - I'm not too sure about other 
> >>>browsers.
> >>>
> >>>The session cookies aren't stored on the clients file system but in
> >>>memory only. Non-session cookies are stored on the file 
> system. When
> >>>you set your cookie with a '0', the data is in memory, and 
> >>>      
> >>>
> >>when you're
> >>    
> >>
> >>>doing "time() - 86400", it's on the file system. Try
> >>>setcookie($projectFolderName, '', 0, '/');
> >>>
> >>>      
> >>>
> >>_______________________________________________
> >>New York PHP Talk
> >>Supporting AMP Technology (Apache/MySQL/PHP)
> >>http://lists.nyphp.org/mailman/listinfo/talk
> >>http://www.newyorkphp.org
> >>
> >>    
> >>
> >_______________________________________________
> >New York PHP Talk
> >Supporting AMP Technology (Apache/MySQL/PHP)
> >http://lists.nyphp.org/mailman/listinfo/talk
> >http://www.newyorkphp.org
> >
> >  
> >
> 
> 
> -- 
> --------------------------------------------------------------
> -------------------
> Phil Powell
> Multimedia Programmer
> BPX Technologies, Inc.
> #: (703) 709-7218 x107 
> Fax: (703) 709-7219
> 
> 	
> 
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
> 



More information about the talk mailing list