Version 1 (modified by Krzysztof Kuliga, 10 years ago) (diff)


This tutorial is an effect of collaboration between Samsung Poland R&D Center and Silesian Univeristy of Technology. It's a part of subject: "Writing tutorial about a WebKit-Efl API"

Author: Krzysztof Kuliga (kkrzysiek89 [at]

The Settings API


The ewk_cookies.h file is designed to manage the browser cookies. It has all of the important functions needed to use cookies (create cookie, delete,) and change their properties(change cookies policy).

Dependency diagram

Parts of WebCore and libraries which are related to ewk_cookies.h

API Module Description


Firstly initialization of the module depends on definition of the cookie object. After creating or during that operation we are obliged to define all the cookie object properties like for example: name, value, domain, path, expiration date. Closer look we will have in the example of use.

Objects Modification

After we created the object and define all of its important values/properties we can do some modifications. The ewk_cookies.h file provides us declaration on several functions that modificate cookie state. Functions:

  • EAPI Eina_Bool ewk_cookies_file_set (const char * filename)
  • EAPI void ewk_cookies_policy_set (Ewk_Cookie_Policy p)
  • EAPI Eina_List* ewk_cookies_get_all (void )
  • EAPI Ewk_Cookie_Policy ewk_cookies_policy_get (void )

Example of use

#include "ewk_cookies.h"  // including the library

// modifying the function that is used after each load of the site
static void on_load_finished(void *user_data, Evas_Object *webview, void *event_info)
	Ewk_cookie *cookie = new Ewk_cookie(); // defining the cookie pointer
	Eina_list  *list = 0; // defining list for storing all the webpage cookies
    const Ewk_Frame_Load_Error *err = (const Ewk_Frame_Load_Error *)event_info;
    const char* text = "~src/Webkit/cookies";
    if (!err)
        info("Succeeded loading page.\n");
    else if (err->is_cancellation)
        info("Load was cancelled.\n");
        info("Failed loading page: %d %s \"%s\", url=%s\n",
             err->code, err->domain, err->description, err->failing_url);
	// checking if any path for storing cookies is set
	//defining cookie properties
	cookie->name = "first_cookie"; //example name for cookie
	cookie->value = 1;
	cookie->domain = err->domain; // we get info about domain from err pointer
	cookie->path = *text;    // setting path which is stored in global variable
	cookie->expires = 0; // setting cookie expiration time
	ewk_cookies_policy_set(SOUP_COOKIE_JAR_ACCEPT_ALWAYS); //setting cookie policy
    else //when we can't set our path for storing cookies
	info("Unable to set path where cookies to be stored.\n");
	list = ewk_cookies_get_all(); // we get all the cookies into list variable
    currentZoom = ewk_view_zoom_get(webview);
    currentZoomLevel = nearest_zoom_level_get(currentZoom);
    info("WebCore Zoom=%f, currentZoomLevel=%d\n", currentZoom, currentZoomLevel);

Example is based on the Tools/EWebLauncher/main.c.