###################################################################
# Copyright (C) 2006 RoyaltyShare, Inc.  All Rights Reserved
# $Id$
###################################################################

package Common::Preference::Session;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Assert;

use base 'Common::Preference';

sub set {
    my $self  = shift;
    my $value = shift;
    assert( $self->name );

    $self->{_value} = $value;
    $self->{_found} = 1;

    my $cookie = Common::RSApp::GetSessionPreferenceCookie();
    $cookie->set( $self->name, $self->value );

    return $self;
}

sub get {
    my $self = shift;
    assert( $self->name );

    my $cookie = Common::RSApp::GetSessionPreferenceCookie();
    $self->{_value} = $cookie->get( $self->name );
    $self->{_found} = defined( $self->value ) ? 1 : undef;

    return $self;
}

1;
