Re: looking for a class that handles cookies and sessions

From: Date: Wed, 27 Jun 2001 14:57:00 +0000
Subject: Re: looking for a class that handles cookies and sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55398@lists.php.net to get a copy of this message
Hi PeterOblivion! On Tue, 26 Jun 2001, PeterOblivion@aol.com wrote: > I need a class that can quickly help me set cookies and sessions, and check > up against them > > anyone have an idea where i can get one like this? > yes http://www.webdev.ro/products/phpx/phpx.tgz luckily enough, Daniel (dt@dnt.ro) put it up on this site so others can have access to it. it includes only the sources w/ no docs, but a simple example follows. quick jumps to the colorful sources are: -> http://www.webdev.ro/products/phpx/code.php?file=ScriptletRequest.php -> http://www.webdev.ro/products/phpx/code.php?file=ScriptletResponse.php -> http://www.webdev.ro/products/phpx/code.php?file=Session.php $request = new HttpScriptletRequest(); $response = new HttpScriptletResponse(); $a_variable = $request->getAttribute('variable.name'); $a_cookie = $request->getCookie('baubau'); etc. the full API of request is a bigger, just have a look, and quite easy to use. /* for `slash trick' browsing u can use this: */ $request->setPathMapping('/module.name/module.entry/module.info'); if ($request->getAttribute('module.name') == 'News') { // do stuff } an so, for an url like: http://www.foo.com/News/ShowNews/123 you have the mapping: 'module.name' -> News 'module.entry' -> ShowNews 'module.info' -> 123 of course u can use any name, just separate them with `/'. /* for session support */ $session = $request->getSession(); $someCart = new Cart(); // to save it to the session $session->setAttribute('cart.items', $someCart); // to get it (AS A COPY - changes aren't saved) $otherCart = $session->getAttribute('cart.items'); // to get it AS A REFERENCE (changes are saved) $otherCart =& $sesion->getAttribute('cart.items'); You can use a $Request object as a containter/spacename for your variables along the request processing to have a more elegant variables control, IMO. Play with it, enhance it and share if you like :) -- teodor

« previous php.general (#55398) next »