Giter Site home page Giter Site logo

mod_cookie_domain's Introduction

Add main domain to cookies

This apache2 module adds the main domain to each cookie set by the webserver or proxied HTTP response. Without the module, it is not possible to set the domain name for a cookie from a virtual host. You can set the domain name of a cookie to a fixed domain, but when there are multiple domains behind a single apache server, apache2 cannot set the domain name of the cookie to the hostname of the request.

This module solves the problem by splitting the value of HTTP header "Host:" by a dot, and taking the last two parts of the value. The last two parts are the domain set on each cookie.

This approaches allows a vhost to set cookies on a subdomain (for example the subdomain "m.example.com") and reuse those cookies when the user is accessing the main domain (in this case "example.com"), or another subdomain.

Usage

For compilation and installation of the apache2 modules, use:

make install

The compiled module will be copied to /usr/lib64/apache2/modules (Gentoo), or /usr/share/apache2/modules (Ubuntu).

You'll probable need root access to install the module there. Therefore, performing make followed by sudo make install is advised. The apache2 server has to be restarted in order to use the module.

Testing

For compilation, installation and testing the module, use:

TEST_URL="http://m.example.com/app/web/sb" make test

The module is successfully working when the cookie set by the HTTP server ends in "; Domain=.example.com".

Make sure to that mod_cookie_domain is loaded, and set as an output filter in one or more apache2 sites. The module can be loaded using:

LoadModule cookie_domain_module /usr/lib/apache2/modules/mod_cookie_domain.so

and, inside a <VirtualHost> section, set as output filter using:

SetOutputFilter cookie_domain

Note: This requires that the apache2 module directory is writable for the user performing make test. This will also restart apache2 to reload the installed module.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.