Tanveer’s Weblog

Entries categorized as ‘PHP’

cakephp : $ajax.observeField and Session lost

July 2, 2008 · 3 Comments

Finlay i made the solution in my style… :)
In my cakePHP project when ever i made any Ajax request to my system… my session was lost.. and the new requested controller and action take the place on my session variable. I was totally mad.. because it takes my localization action away… The thing is when ever i change my combo box.. it calls the ajax request and reset my language session value and if any one click on the language flag on that moment my page layout was lost and broke down… :(

Solutions:

1. Change the CAKE_SECURITY in app core.php to a level of medium or low
(don't worry it will not make any hole in the system and someone says that it can be the solution anyway..)
2. In app_controller set
var $components=array('RequestHandler');
3. Now, inside the beforeRender() method...add
$current_session_value = $this->Session->read('my_sess_var') ;
// this is the session which i want to have it
//What i did just check is ther any Ajax request has occurred.. so i use isAjax()
if ( $this->RequestHandler->isAjax() ) {
$this->Session->write('my_sess_var', null ); //i reset that session which was use to store
$this->Session->write('my_sess_var', $current_session_value ); // re-assign again
}

yahoo…. my problem is solved… no i can change my language whenever i want…

:)

Categories: PHP · Tips' n Tricks' · cakePHP

PHPIDS (PHP-Intrusion Detection System)

June 20, 2008 · 1 Comment

” The PHPIDS is a system that is meant to be an additional layer of security for any PHP based website or web application. In fact, this layer does not filter input – that would be a task for different layers – but it makes sure that no potential attack against the application goes unnoticed. “

PHPIDS is a simple recognizer. When an attacker tries to break a site and reacts in exactly the way you want it to. Based on a set of approved and heavily tested filter rules any attack is given a numerical impact rating which makes it easy to decide what kind of action should follow the hacking attempt. This could range from simple logging to sending out an emergency mail to the development team, displaying a warning message for the attacker or even ending the user’s session.

see demo http://demo.php-ids.org/
More about PHPIDS click here

Categories: PHP