Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for advice how to login on Geoserver from php. I found much tutorial how to work with Geoserver through REST api and cURL: create workspaces, stores, etc. But still cant find how to login on Geoserver and still login to whole session. Its possible? In forums i find something but its not work.
Any advice?


I change Acegi security to Spring Security and now code looks:

function loginGeoserver($username, $password) {

$geoserverURL = "http://localhost:8080/geoserver/j_acegi_security_check";

$post = http_build_query(array(
        "username" => $username,
        "password" => $password,

$context = stream_context_create(array("http"=>array(
    "method" => "POST",
    "header" => "Content-Type: application/x-www-form-urlencoded\r\n" .
            "Content-Length: ". strlen($post) . "\r\n",
    "content" => $post,

$page = file_get_contents($geoserverURL, false, $context);

for($i = 0; $i < sizeof($http_response_header); $i++){

    $headerLine = $http_response_header[$i];

    $pos = strpos($headerLine, 'Set-Cookie');

    if ($pos === 0) {
            $str = explode("=",$headerLine);
            $value = explode(";",$str[1]);
            $cookieValue = $value[0];


$cookieName = "JSESSIONID";
$cookieDomain = "http://localhost:8080";
$cookiePath = "/geoserver";
$cookieExpiration = 0;

echo $page;
return $cookieValue;

Now its return Geoserver index page but nothing more i still can't log in. How can i make Acegi authorization?

share|improve this question
up vote 1 down vote accepted

I think i found answer. I use php for create session. So i get session id, but its just php session NOT Geoserver becouse its Java applicaton. So from php i can just get session id.
If im wrong give me better answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.