request: cookie check when member first visit website

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
dkny7007
Regular
Posts: 9
Joined: Mon Sep 20, 2004 3:33 am

request: cookie check when member first visit website

Post 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.. :)
dkny7007
Regular
Posts: 9
Joined: Mon Sep 20, 2004 3:33 am

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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;
        }
    }
}
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply