473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sharing variables (beginner's question)

How can I share variables between two processes?
Here is my problem?

File test1.php:
-------------------------------------------------------------------
<?php
session_start() ;
$var1="This should";
$var2="be displayed";
$_SESSION[ 'var1' ]=$var1;
$_SESSION[ 'var2' ]=$var2;
if (session_is_reg istered('var1') ) {
print "Var1 is registered<br>" ;
}
if (session_is_reg istered('var2') ) {
print "Var2 is registered<br>" ;
}
print "<A HREF=/work/test2.php>Secon d File</A>";
?>

File test2.php
-------------------------------------------------------------------
<?php
if (session_is_reg istered('var1') ) {
print "test2:Var1 is registered<br>" ;
}
if (session_is_reg istered('var2') ) {
print "test2:Var2 is registered<br>" ;
}

$var1=$_SESSION[ 'var1' ];
$var2=$_SESSION[ 'var2' ];
print "$var1 $var2 <br>";
?>
Nothing gets displayed. I think that the problem lies in the fact that
these two files are handled by two processes, but I also think that
httpd process should be able to get the cookie from the browser and
read the sess* file containing the variables:
var1|s:11:"This should";var2|s: 12:"be displayed";

How can I achieve proper sharing of the information, short of developing
a complex scheme with shmop, which would mean complete relink and,
basically, reinstallation of PHP? I apologize in advance if the question
is elementary, but I was absolutely unable to find the answer in either
PHP online pages or O'Reilly book.

--
Trust me, I know what I'm doing. (Sledge Hammer)

Jul 17 '05 #1
1 2731
Mladen Gogala wrote:
How can I share variables between two processes?


You *must* start the session in *every* script that uses session
variables.
*************** *************** *************** *************** ********

<quote src="http://www.php.net/session_is_regi stered" edited="true">

*CAUTION*

DO NOT use session_is_regi stered() and $_SESSION in the same script!

</quote>

*************** *************** *************** *************** ********

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2465
by: Mladen Gogala | last post by:
How can I share session registered variables between different processes? Here is my problem: File 1: ----------------------------------------------------------------------- <?php session_start(); $var1="This should"; $var2="be displayed"; $_SESSION=$var1; $_SESSION=$var2;
42
3189
by: Dan | last post by:
Hello, I have trouble with class calling. I am calling getvolume() with succes in the function CreateCircle but it do not want to call it in ShowCircle() function. I am staying in the same class. I thought that was the point of encapsulation. When the function ShowCircle() is called I get very large number -1.07374e+008 can anyone help me ?
1
1397
by: DaVinci | last post by:
I did a google web & group search and didn't find an answer to my question so... here we go. Will try to keep it short. (I am not a complete beginner but am still pretty low on the food chain). Two programs on two different machines. Program 1 is given values for multiple variables. Program 1 then sends everything to Program 2 in an ascii character format. Program 2 then needs to parse the input buffer, extract the type of data and...
3
1683
by: Selden McCabe | last post by:
I have an old ASP project, and I'm adding some functionality in ASP.Net. I stuff some information into Session variables in the ASP page, then redirect to the ASP.Net page. But when I pull up the session variables, they are empty! Is it possible to share session variables this way? Thanks,
4
1349
by: W Akthar | last post by:
Hi, I need to pass session state variables across different web applications. Firstly is this possible and secondly can someone show me how please??
4
2272
by: DaveM | last post by:
Although I've programmed for fun - on and off - since the mid 70's, I'm definitely an OO (and specifically Python) beginner. My first question is about global variables. Are they, as I'm starting to suspect, a sin against God or just best avoided? Having got my current application working using them, I'm not sure whether I want to refactor it, but equally, I'd like to write the best code I can. Secondly (and this is related), if you...
2
1251
by: bhawna.email | last post by:
Can we share a variable between 2 methods withour making the variable as static?
1
2019
by: David Belohrad | last post by:
Dear All, could someone give a hint? I'd like to share the resources as follows: A shared class which works as counter of number of shared resources: class Shared { public: Q_PCBShared() : n_count (1) { };
6
1727
by: awhan.iitk | last post by:
I have a set of variables that I want to share across mulitple c++ files. I was using the extern method so far. Is there any other way to do the same. The variables are not constants and I get the values during run time.
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.