
#include <rude/session.h>
using namespace rude;

void doSomething();

int main(void)
{

	// Set Up Config Persistance
	//
	Session::setPersistanceMethod("config");
	Session::setSessionDirectory("/tmp/sessions");

	// Configure cookie information
	//
	Session::setPath("/");
	Session::setDomain(".example.com");
	Session::setCookieIdentifer("SESSIONID");

	// Obtain the session instance before doing any CGI, since new sessions need to
	//	send an HTTP cookie header
	//
	Session *session = Session::getSession();


	// Anywhere in the application, you can obtain the session and use it
	//
	doSomething();



	// New Sessions have to be saved
	//
	if(session->isNew())
	{
		if(!session->save())
		{
			// cout << "Error saving session : " << session->getError() << "\n";
		}
	}

	// Clean up everything
	//
	delete session;

}


void doSomething()
{
	Session *session=Session::getSession();

	session->addValue("color", "red");
	session->setIntValue("size", 34);
	session->setDoubleValue("price", 25.33);
	session->setBoolValue("isHungry", true);

	session->deleteValue("price");

	bool hungry=session->getBoolValue("isHungry");
	const char *color=session->getValue("color");
	double price=session->getDoubleValue("price");
	int thesize=session->getIntValue("thesize");

	// save the changes
	//
	session->save();

}

