curl and session handling

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

curl and session handling

Post by SomeOne »

i use CURL to get content of file...
i use session and now i wnat that curl use the already opened session becouse in session i have some strings the curl needs, to gret the proper output of grabed PHP file...
get it?
again :P
1. i use
session_start();
$_SESSION['var1'] = "this";

2. i use curl to get a content of PHP file and i need a session var1 parameter to have the output i want...
i have tryed several things though...nothing seems to work...
i have an idea to tell curl to use already opened session....though....dont know how to do that?
anyone?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

code, please.
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

CURL code

Code: Select all

$url = "$domena$izpis"; //some php file
 $ch = curl_init();
		curl_setopt($ch, CURLOPT_COOKIE, "mycookie"); //i use my cookie in MY session
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
		curl_setopt($ch, CURLOPT_POST, 1);
//		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_TIMEOUT, 120);
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  //Windows 2003 Compatibility
		$response = curl_exec($ch);
		curl_close($ch);
//then i write $response to file like
	if ($handlex = fopen("$datoteka_html", "w"))
	{
	  fwrite($handlex, $response);
	  fclose($handlex);
	  echo "OK";
	  }else{
	  echo "ERROR";
	  }
the code of session

Code: Select all

session_start();
include_once'settings.php';
  $username = $_POST['username'];
  if (file_exists("$users/$username.php"))
{
  $user = file_get_contents("$users/$username.php");
  $user_name = explode ("=", $user);
  $pass_is = $user_name[1];
			//  pass ok
  $password = $_POST['password'];
    if ($pass_is == $password){

  $_SESSION['is_logged']=1;
  setcookie("NewsLimonet", $username, time()+60*60*24*30);  /* expire in 30 days */
  session_set_cookie_params("mycookie"); 

  } else {
  $_SESSION['is_logged']=0;
  }
}
hope this help?

p.s.: @feyd thnx
:D
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

anyone?
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

:roll:
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

4. All users of any level are restricted from bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not recieve a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
viewtopic.php?t=30037
Post Reply