0

I want to send an html email from my script. I get the email's html using file_get_contents - but I found out the $_SESSION isn't shared between the 2 pages (and other_script.php needs some data that is stored in the $_SESSION array).

this is the code in my send email function:

$url ="OTHER_SCRIPT.php";
$html = file_get_contents($url);
$from ;
$crlf = "\r\n";
$mime = @new Mail_mime($crlf); 
@$mime->setHTMLBody($html);  
//SEND MAIL...

Is there another way to get the output of a script to a variable that will share the session data? or a way to make the $_SESSION data available to my other_script.php?

Joe
  • 15,205
  • 8
  • 49
  • 56
Yuval
  • 504
  • 7
  • 17

3 Answers3

3

You are probably not writing session_start() in both pages.

All the $_SESSIONS are shared between your PHP pages if they have session_start() written.

pzin
  • 4,200
  • 2
  • 28
  • 49
Afonso Matos
  • 75
  • 1
  • 9
1

You have two methods for that :

1) You can use writing session_start() on the both pages

2) can using PHPSESSID as the link discussed earlier

Community
  • 1
  • 1
Rohitashv Singhal
  • 4,517
  • 13
  • 57
  • 105
0

You can try to use PHPSESSID :

$url ="OTHER_SCRIPT.php?PHPSESSID=".session_id();

Here a link.

Community
  • 1
  • 1
Pierrickouw
  • 4,644
  • 1
  • 30
  • 29