Page 1 of 1

request: cookie check when member first visit website

Posted: Sun Aug 20, 2006 6:22 pm
by dkny7007
Hi there, Im using s9y for my main blog, and i like it so far, but im still looking for a plugin that does this function: when a member first visit my blog, ex: www.something.com , then it checked members cookie to see wheather members has visited.

- if not, a html page appears. so after reading the meesage , members can click "refresh" to direct back to the main blog. (cuz it just got the cookie)

- if yes, it just direct to the main blog, and ( and cookie can lasts 1 day). So i can create different message evey day..

please help me make this plug, would be really appreciated.. :)

Posted: Mon Aug 21, 2006 10:31 am
by dkny7007
Hellp??? can any one plz help me create this plugin, or guild me how to modify the code ..i really need it..

Thanks

Posted: Mon Aug 21, 2006 10:47 am
by garvinhicking
Hi!

You can create a plugin that listens on the "frontend_configure" hook and make the redirection.

Something along these lines (untested):

Code: Select all

<?php

class serendipity_event_dkny extends serendipity_event {
    function introspect(&$propbag) {
        global $serendipity;
        
        $propbag->add('name',          'DKNY');
        $propbag->add('description',   '');
        $propbag->add('stackable',     false);
        $propbag->add('author',        'Garvin Hicking');
        $propbag->add('version',       '1.0');
        $propbag->add('requirements',  array(
            'serendipity' => '0.8',
            'php'         => '4.1.0'
        ));
        $propbag->add('event_hooks',    array(
            'frontend_configure'   => true,
        ));
        $propbag->add('groups', array('BACKEND_FEATURES'));
    }

    function event_hook($event, &$bag, &$eventData, $addData = null) {
        global $serendipity;

        $hooks = &$bag->get('event_hooks');
        
        if (isset($hooks[$event])) {
            switch($event) {
                case 'frontend_configure':
                    if (!$_COOKIE['membercookie']) {
                        setcookie('membercookie', 'true', time()+86400);
                        header('Location: http://your/member/url/or/some/other/static/page');
                    }
                    return true;
                    break;

                   
                default:
                    return true;
                    break;
            }
        } else {
            return false;
        }
    }
}