how i can get the cookie of user session?

Hi everybody,

Well, i have created an login system that allow me to get some information about the users , such as “Human tasks”. If the user and password are correct , then will be showing a main page that will contain all the tasks that this user has. This tasks are a links that allow the user to access in them., so if the user do click in one of them automatically it goes to bonita task form, but if didn’t previously logged in session of bonita portal, will showing the bonita portal login system. so what i want to do is to avoid this behavior.

regards

Just use javascript

var x = document.cookie;

works for us, then again depends on what you want to do with it.

regards
Seán

Thanks for your reply but once the cookie has been goten , how i can use it , that is how i can do that when user do click in some task link , that automatically goes to the corresponding form.

as you can see , this code only serves me to access to the task form, so it is an stupid code , because it goes to the task, regardless which user has loged in session. So , this behavior is what i want to change. is possible to start a session in bonita portal automatically ?

echo"<td><a href='http://localhost:8080/bonita/portal/homepage#?id=$AIID&_p=performTask&_pf=1' id='link_FormBonita".$id."' target='central'>".$NomTasca."</a></td>";

Hi,

I’m very confuse, so i going to see if i understood well. As the following code indicates , in order to retrieve some user information, i’m using methods of class, each methods of this class, has a diferent behavior, such as : get human tasks and so on. If you take a look in this code , we can see that it created a cookie named “cookie_LOGIN.txt”, into login method and “cookie_logoutservice.tx” into logout method, so, how this works?, that is, i must to put all “php” files in the same folder where are there the file of cookie?

public function Login($conexio,$user,$password){
	
		$baseURL = 'http://localhost:8080/bonita/';
		//$data = array('username' =>'walter.bates', 'password' => 'bpm', 'redirect' => 'false');
		$data = array('username' =>$user, 'password' => $password, 'redirect' => 'false');
		curl_setopt($conexio, CURLOPT_URL, $baseURL.'loginservice');
		curl_setopt($conexio, CURLOPT_POST, 1);
		curl_setopt($conexio, CURLOPT_POSTFIELDS,http_build_query($data));
		curl_setopt($conexio, CURLOPT_RETURNTRANSFER, true);	
		$tmpfname = dirname(__FILE__).'/cookie_LOGIN.txt';  
    	curl_setopt($conexio, CURLOPT_COOKIEJAR, $tmpfname);
   		curl_setopt($conexio, CURLOPT_COOKIEFILE, $tmpfname);
		curl_setopt($conexio, CURLOPT_VERBOSE, true);
		$verbose = fopen('curlLOGIN.log', 'a+');
		curl_setopt($conexio, CURLOPT_STDERR, $verbose);
		$logejat=curl_exec($conexio);
		return $logejat;
	}


	public function Logout($conexio){
	
	    $baseURL = 'http://localhost:8080/bonita/logoutservice';
		curl_setopt($conexio, CURLOPT_URL,$baseURL);	
		curl_setopt($conexio, CURLOPT_POST, 0);
		curl_setopt($conexio, CURLOPT_RETURNTRANSFER, true);
		$tmpfname = dirname(__FILE__).'/cookie_logoutservice.txt';  
		curl_setopt($conexio, CURLOPT_COOKIEJAR, $tmpfname);
   		curl_setopt($conexio, CURLOPT_COOKIEFILE, $tmpfname);
		$logout=curl_exec($conexio);
		curl_close($conexio);
		return $logout;
		
	}

Sorry you’re using PHP, I don’t support PHP.

Besides shouldn’t you be using the Bonita cookie and not your own cookie?

This from the REST API Overview

Authenticate to Bonita BPM

Calls to the Web REST API require you to first log in as a user registered in the Engine database.

To log in, use the following request:

Request URL http://host:port/bonita/loginservice

This call generates a cookie, which must be set on each subsequent call. If the Web REST is being used in an application running in a web browser, this is handled automatically by the browser.

From my understanding you have to Login and then GET the cookie from the system

see here: http://www.pontikis.net/blog/create-cookies-php-javascript

regards
Seán

PS: If this reply answers your question, please mark as resolved.