Re: [PHP] store array into session variable and get it back later

2008-10-02 Thread Stut

On 1 Oct 2008, at 20:42, Per Jessen wrote:

Stut wrote:

On 1 Oct 2008, at 11:40, Per Jessen wrote:

Alain Roger wrote:


how can i get the 'name' value for each row in this session stored
array ? thx.


You haven't stored an array in the session, you've tried to store an
object of class CBreadcrumb. Which AFAIK isn't supported.


It is supported but you need to be careful about resources in the
class. You can handle these gracefully using the __sleep and __wake
magic methods. You also need to make sure the class has been loaded
before starting the session or have an __autoload defined.


Thanks, I was not aware.  Very clear and succinct explanation, btw.


No worries. I find it best to limit myself to responding quickly,  
otherwise I get nothing else done! It also forces me to get straight  
to the point.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Per Jessen
Alain Roger wrote:

 how can i get the 'name' value for each row in this session stored
 array ? thx.

You haven't stored an array in the session, you've tried to store an
object of class CBreadcrumb. Which AFAIK isn't supported.  


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Stut

On 1 Oct 2008, at 11:40, Per Jessen wrote:


Alain Roger wrote:


how can i get the 'name' value for each row in this session stored
array ? thx.


You haven't stored an array in the session, you've tried to store an
object of class CBreadcrumb. Which AFAIK isn't supported.


It is supported but you need to be careful about resources in the  
class. You can handle these gracefully using the __sleep and __wake  
magic methods. You also need to make sure the class has been loaded  
before starting the session or have an __autoload defined.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Frank Arensmeier

1 okt 2008 kl. 12.31 skrev Alain Roger:

...





later on i try to use the content of this array, bt without success.
Here is what i do:

$bci = array($_SESSION['bc']);

array_push($bci,$_SESSION['bc']);

foreach($bci as $key=$value)
{
 echo bci : .$bci[$key]['name'];
 echo br/;
}



how can i get the 'name' value for each row in this session stored  
array ?

thx.


...

The function you need to look into is called serialize.

http://www.php.net/manual/en/function.serialize.php

//frank


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Alain Roger
On Wed, Oct 1, 2008 at 2:43 PM, Frank Arensmeier [EMAIL PROTECTED] wrote:

 1 okt 2008 kl. 12.31 skrev Alain Roger:

 ...



  later on i try to use the content of this array, bt without success.
 Here is what i do:

 $bci = array($_SESSION['bc']);

 array_push($bci,$_SESSION['bc']);

 foreach($bci as $key=$value)
 {
  echo bci : .$bci[$key]['name'];
  echo br/;
 }


 how can i get the 'name' value for each row in this session stored array ?
 thx.

  ...

 The function you need to look into is called serialize.

 http://www.php.net/manual/en/function.serialize.php

 //frank

This is what i did afterall, but when i unserialize it like this way:
$bci = unserialize($_SESSION['bc']);
foreach($bci as $key=$value)
{
echo bci : .$key;
echo br/;
}

i get absolutely the same result as the code below.
in fact $key returns me the 2 variables member of the Class. but not the
value stored inside them.
any idea ?



-- 
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Alain Roger


  later on i try to use the content of this array, bt without success.
 Here is what i do:

 $bci = array($_SESSION['bc']);

 array_push($bci,$_SESSION['bc']);

 foreach($bci as $key=$value)
 {
  echo bci : .$bci[$key]['name'];
  echo br/;
 }


 how can i get the 'name' value for each row in this session stored array
 ?
 thx.

  ...

 The function you need to look into is called serialize.

 http://www.php.net/manual/en/function.serialize.php

 //frank

 This is what i did afterall, but when i unserialize it like this way:
 $bci = unserialize($_SESSION['bc']);
 foreach($bci as $key=$value)
 {
 echo bci : .$key;
 echo br/;
 }

 i get absolutely the same result as the code below.
 in fact $key returns me the 2 variables member of the Class. but not the
 value stored inside them.
 any idea ?


 so here is what i've decided to use:
for ($row=0;$row=count($bci-crumb);$row++)
{
echo br/value[$row]['name'] :
.$bci-crumb[$row]['name'].br/;
echo br/value[$row]['link'] :
.$bci-crumb[$row]['link'].br/;
echo br/value[$row]['id'] : .$bci-crumb[$row]['id'].br/;
}
and it works like a charm.
but how can i optimize it ?
i mean foreach could do the work better ?


Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Thodoris




This is what i did afterall, but when i unserialize it like this way:
$bci = unserialize($_SESSION['bc']);
foreach($bci as $key=$value)
{
echo bci : .$key;
echo br/;
}

i get absolutely the same result as the code below.
in fact $key returns me the 2 variables member of the Class. but not the
value stored inside them.
any idea ?


so here is what i've decided to use:


for ($row=0;$row=count($bci-crumb);$row++)
{
echo br/value[$row]['name'] :
.$bci-crumb[$row]['name'].br/;
echo br/value[$row]['link'] :
.$bci-crumb[$row]['link'].br/;
echo br/value[$row]['id'] : .$bci-crumb[$row]['id'].br/;
}
and it works like a charm.
but how can i optimize it ?
i mean foreach could do the work better ?

  


Since it is not necessary to store the object in the session at least 
AFAIK I wonder why don't you just store a simple array.


You will not need to worry for anything.

--
Thodoris



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Larry Brown
how about:

$bci = $_SESSION['bc'];

foreach($bci-crumb as myCrumb)
{
echo br/value['name'] :.$myCrumb['name'].br/;
echo br/value['link'] :.$myCrumb['link'].br/;
echo br/value['id'] : .$myCrumb['id'].br/;
}

You are wanting to loop through the crumbs rather than looping objects.
There is only one object you are sending over through  the session and
multiple crumbs right?


On Wed, 2008-10-01 at 17:04 +0200, Alain Roger wrote:
 
 
   later on i try to use the content of this array, bt without success.
  Here is what i do:
 
  $bci = array($_SESSION['bc']);
 
  array_push($bci,$_SESSION['bc']);
 
  foreach($bci as $key=$value)
  {
   echo bci : .$bci[$key]['name'];
   echo br/;
  }
 
 
  how can i get the 'name' value for each row in this session stored array
  ?
  thx.
 
   ...
 
  The function you need to look into is called serialize.
 
  http://www.php.net/manual/en/function.serialize.php
 
  //frank
 
  This is what i did afterall, but when i unserialize it like this way:
  $bci = unserialize($_SESSION['bc']);
  foreach($bci as $key=$value)
  {
  echo bci : .$key;
  echo br/;
  }
 
  i get absolutely the same result as the code below.
  in fact $key returns me the 2 variables member of the Class. but not the
  value stored inside them.
  any idea ?
 
 
  so here is what i've decided to use:
 for ($row=0;$row=count($bci-crumb);$row++)
 {
 echo br/value[$row]['name'] :
 .$bci-crumb[$row]['name'].br/;
 echo br/value[$row]['link'] :
 .$bci-crumb[$row]['link'].br/;
 echo br/value[$row]['id'] : .$bci-crumb[$row]['id'].br/;
 }
 and it works like a charm.
 but how can i optimize it ?
 i mean foreach could do the work better ?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] store array into session variable and get it back later

2008-10-01 Thread Per Jessen
Stut wrote:

 On 1 Oct 2008, at 11:40, Per Jessen wrote:
 
 Alain Roger wrote:

 how can i get the 'name' value for each row in this session stored
 array ? thx.

 You haven't stored an array in the session, you've tried to store an
 object of class CBreadcrumb. Which AFAIK isn't supported.
 
 It is supported but you need to be careful about resources in the
 class. You can handle these gracefully using the __sleep and __wake
 magic methods. You also need to make sure the class has been loaded
 before starting the session or have an __autoload defined.

Thanks, I was not aware.  Very clear and succinct explanation, btw. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-29 Thread Pradeep D'souza
Hi

Try this

$_SESSION[my_session] = array(item_1 = Some Value , item_2 = Some
Value2 , item_3 = Some Value3);

This allow s you to store the array in the session

Pradeep DSouza
Naharonline.com


- Original Message -
From: Pushpinder Singh Garcha [EMAIL PROTECTED]
To: CPT John W. Holmes [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 1:00 AM
Subject: Re: [PHP] Store array as Session Variable


 $details is empty !!

 Thanks
 --Pushpinder


 On Monday, July 28, 2003, at 03:31 PM, CPT John W. Holmes wrote:

  $details is an array (just like $company_name was). Try to view
  print_r($details); and see what you get.
 
  ---John Holmes...
 
  - Original Message -
  From: Pushpinder Singh Garcha [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Monday, July 28, 2003 3:18 PM
  Subject: [PHP] Store array as Session Variable
 
 
  hello All,
 
I am trying to store an array as a session variable.
 
  while ($row = mysql_fetch_array($result))
  {
  if ( !is_array($company_name) ) $company_name = array();
 array_push($company_name, $row['company']);
 
  // try to register session variable
   $_SESSION['link'] = $company_name;
 
  }
 
 
  Now when I try to access this session variable in another file...I am
  getting a junk value.I am not sure if I am getting this right.
 
  $details = $_SESSION['link'];
echo LINK: .$details.br;
 
 
  Can some one fill me in on this. Appreciate it !  Thanks in advance.
 
  --Pushpinder Singh
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Chris Shiflett
--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
   I am trying to store an array as a session variable.

Based on your code, it looked like your question had little to do with storing
an array as a session variable. To do that, this works:

$_SESSION['myarray'] = $myarray;

 while ($row = mysql_fetch_array($result))
 {
  if (!is_array($company_name))
   $company_name = array();  
  array_push($company_name, $row['company']);

I cleaned up your formatting a bit, so that we can read your code more easily.
Can you explain what you intend to do here?

It looks to me like you expect $company_name to be populated during the $row =
mysql_fetch_array($result) part, since you check whether it is an array during
every iteration of the loop. Then, you are erasing its value unless it is an
array. Is this right so far? Is this what you want to do? I think this bit of
code is likely where your problem lies.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread CPT John W. Holmes
$details is an array (just like $company_name was). Try to view
print_r($details); and see what you get.

---John Holmes...

- Original Message - 
From: Pushpinder Singh Garcha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 3:18 PM
Subject: [PHP] Store array as Session Variable


hello All,

  I am trying to store an array as a session variable.

while ($row = mysql_fetch_array($result))
{
if ( !is_array($company_name) ) $company_name = array();
   array_push($company_name, $row['company']);

// try to register session variable
 $_SESSION['link'] = $company_name;

}


Now when I try to access this session variable in another file...I am
getting a junk value.I am not sure if I am getting this right.

$details = $_SESSION['link'];
  echo LINK: .$details.br;


Can some one fill me in on this. Appreciate it !  Thanks in advance.

--Pushpinder Singh


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Pushpinder Singh Garcha
$details is empty !!

Thanks
--Pushpinder
On Monday, July 28, 2003, at 03:31 PM, CPT John W. Holmes wrote:

$details is an array (just like $company_name was). Try to view
print_r($details); and see what you get.
---John Holmes...

- Original Message -
From: Pushpinder Singh Garcha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 3:18 PM
Subject: [PHP] Store array as Session Variable
hello All,

  I am trying to store an array as a session variable.

while ($row = mysql_fetch_array($result))
{
if ( !is_array($company_name) ) $company_name = array();
   array_push($company_name, $row['company']);
// try to register session variable
 $_SESSION['link'] = $company_name;
}

Now when I try to access this session variable in another file...I am
getting a junk value.I am not sure if I am getting this right.
$details = $_SESSION['link'];
  echo LINK: .$details.br;
Can some one fill me in on this. Appreciate it !  Thanks in advance.

--Pushpinder Singh



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Store array as Session Variable

2003-07-28 Thread Chris Shiflett
--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
 I am trying to store the value in row['company'] in an array
 called $company_name.

I see now. I think you might find this a bit simpler (if I understand
correctly):

$company_name = array();
while ($row = mysql_fetch_assoc($result))
{
 $company_name[] = $row['company'];
}

Also, at this point, you should probably examine the contents of $company_name
before bothering with the session stuff. You may be having trouble with your
query or something that is totally unrelated to sessions. Try John's suggestion
of print_r() by doing something like this:

echo 'pre';
print_r($company_name);
echo '/pre';

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Pushpinder Singh Garcha
Thanks Chris,

I am able to see the contents of the $company_name array. The next  
part involves storing this as a session variable.

I am trying to link this page to another search page using the  a  
href=\full-profile.php?name=.$row['company']. \--Link--/a

while ($row = mysql_fetch_assoc($result))
{
TR BGCOLOR=$bgcolor
 TD align=\left\font color=\#66\ size=\1\  
face=\Verdana, Arial, Helvetica,  
sans-serif\$row[company]/font/TD
  TD align=\left\font color=\#66\ size=\1\  
face=\Verdana, Arial, Helvetica,  sans-serif\$row[name_1]/font/TD
   TD align=\left\font color=\#66\ size=\1\  
face=\Verdana, Arial, Helvetica,  
sans-serif\$row[phone_1]/font/TD
	TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
Arial, Helvetica, sans-serif\$row[city]/font/TD
	TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
Arial, Helvetica, sans-serif\$row[url]/font/TD
	TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
Arial, Helvetica, sans-serif\$row[email_1]/font/TD
   TD align=\center\font color=\#33\ size=\1\  
face=\Verdana, Arial, Helvetica, sans-serif\a  
href=\full-profile.php?name=.$row['company'].\--Link--/a/ 
font/TD	/TR;

$company_name[] = $row['company'];
 // try to register the variable
$_SESSION['link'] = $company_name;
}


  What would be the best way to register the array $company_name as a  
session var and access it on the following page. $_SESSION['link'] =  
$company_name;
does not seem to work since it gives NULL when i try to echo  
$_SESSION['link'];

Thanks in advance
--Pushpinder


On Monday, July 28, 2003, at 03:43 PM, Chris Shiflett wrote:

--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
I am trying to store the value in row['company'] in an array
called $company_name.
I see now. I think you might find this a bit simpler (if I understand
correctly):
$company_name = array();
while ($row = mysql_fetch_assoc($result))
{
 $company_name[] = $row['company'];
}
Also, at this point, you should probably examine the contents of  
$company_name
before bothering with the session stuff. You may be having trouble  
with your
query or something that is totally unrelated to sessions. Try John's  
suggestion
of print_r() by doing something like this:

echo 'pre';
print_r($company_name);
echo '/pre';
Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/


Re: [PHP] Store array as Session Variable

2003-07-28 Thread CPT John W. Holmes
  I am able to see the contents of the $company_name array. The next
 part involves storing this as a session variable.

 I am trying to link this page to another search page using the  a
 href=\full-profile.php?name=.$row['company']. \--Link--/a

If you're passing the company name in the URL, why are you adding the entire
array to the session? You can just use $_GET['name'] to get the name of the
company that was clicked on...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Chris Shiflett
--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
 I am able to see the contents of the $company_name array. The
 next part involves storing this as a session variable.

Assuming $company_name is set correctly, as you verified, this should suffice:

$_SESSION['company_name'] = $company_name;

I should mention that you will need a session_start() call on the page you wish
to set session variables on as well as any page that you wish to read session
variables from.

 I am trying to link this page to another search page using the  a  
 href=\full-profile.php?name=.$row['company']. \--Link--/a
 
  while ($row = mysql_fetch_assoc($result))
  {
  TR BGCOLOR=$bgcolor
   TD align=\left\font color=\#66\ size=\1\  
  face=\Verdana, Arial, Helvetica,  
  sans-serif\$row[company]/font/TD
TD align=\left\font color=\#66\ size=\1\  
  face=\Verdana, Arial, Helvetica,  sans-serif\$row[name_1]/font/TD
 TD align=\left\font color=\#66\ size=\1\  
  face=\Verdana, Arial, Helvetica,  
  sans-serif\$row[phone_1]/font/TD
  TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
  Arial, Helvetica, sans-serif\$row[city]/font/TD
  TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
  Arial, Helvetica, sans-serif\$row[url]/font/TD
  TD align=\left\font color=\#66\ size=\1\ face=\Verdana,  
  Arial, Helvetica, sans-serif\$row[email_1]/font/TD
 TD align=\center\font color=\#33\ size=\1\  
  face=\Verdana, Arial, Helvetica, sans-serif\a  
  href=\full-profile.php?name=.$row['company'].\--Link--/a/ 
  font/TD  /TR;

This is about the best example I've seen as to why stylesheets are handy. :-)

Is there an echo in there that I missed? I don't see how this is being output.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Pushpinder Singh Garcha
Thanks John,

  I used the $_GET['name'] on the next page to access the 
selection.

http://psg.local/~psgarcha/CRM/full-profile.php?name=jack
http://psg.local/~psgarcha/CRM/full-profile.php?name=tim
http://psg.local/~psgarcha/CRM/full-profile.php?name=mary
http://psg.local/~psgarcha/CRM/full-profile.php?name=evian
My full-profile.php page first checks for a session before displaying 
the results.

However if I decided to use the sessions approach how would I go about 
it ? I am just curious to find out why $_SESSION['company_name'] = 
$company_name; duz not werk for me !

Thanks in advance
--Pushpinder




On Monday, July 28, 2003, at 04:14 PM, CPT John W. Holmes wrote:

 I am able to see the contents of the $company_name array. The 
next
part involves storing this as a session variable.

I am trying to link this page to another search page using the  a
href=\full-profile.php?name=.$row['company']. \--Link--/a
If you're passing the company name in the URL, why are you adding the 
entire
array to the session? You can just use $_GET['name'] to get the name 
of the
company that was clicked on...

---John Holmes...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Store array as Session Variable

2003-07-28 Thread Chris Shiflett
--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
 However if I decided to use the sessions approach how would I go about 
 it? I am just curious to find out why $_SESSION['company_name'] = 
 $company_name; duz not werk for me!

Did you use session_start() like I mentioned?

If so, you are probably making an error somewhere due to the complexity of your
script(s). If you want to learn how to use sessions, focus on that and nothing
else (e.g., forget interacting with a database, passing URL variables, etc.).
Start with a simple example, get that to work, then integrate it into what you
are trying to do.

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Pushpinder Singh Garcha
Hello Chris,

  I am using session_start(). All the pages after the login page use 
sessions and will redirect the user to the login page, if he/she is NOT 
logged in. So I am guessing the error lies in my logic somewhere.

Thanks again.
--Pushpinder
On Monday, July 28, 2003, at 04:51 PM, Chris Shiflett wrote:

--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
However if I decided to use the sessions approach how would I go about
it? I am just curious to find out why $_SESSION['company_name'] =
$company_name; duz not werk for me!
Did you use session_start() like I mentioned?

If so, you are probably making an error somewhere due to the 
complexity of your
script(s). If you want to learn how to use sessions, focus on that and 
nothing
else (e.g., forget interacting with a database, passing URL variables, 
etc.).
Start with a simple example, get that to work, then integrate it into 
what you
are trying to do.

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Store array as Session Variable

2003-07-28 Thread Chris Shiflett
--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
 I am using session_start(). All the pages after the login page use 
 sessions and will redirect the user to the login page, if he/she is
 NOT logged in.

You're not using IIS by chance are you? If so, I think you will find this link
helpful:

http://marc.theaimsgroup.com/?l=php-generalm=102929828515647w=2

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Store array as Session Variable

2003-07-28 Thread Pushpinder Singh Garcha
Hello Chris,

 I am using Apache webserver on the MAc Jaguar OS Platform

Regards
--Pushpinder
On Monday, July 28, 2003, at 05:02 PM, Chris Shiflett wrote:

--- Pushpinder Singh Garcha [EMAIL PROTECTED] wrote:
I am using session_start(). All the pages after the login page use
sessions and will redirect the user to the login page, if he/she is
NOT logged in.
You're not using IIS by chance are you? If so, I think you will find 
this link
helpful:

http://marc.theaimsgroup.com/?l=php-generalm=102929828515647w=2

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Store array as Session Variable

2003-07-28 Thread Rob Adams

Pushpinder Singh Garcha [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 $details is empty !!


I'd check your sql query and see if any rows are being returned.  Also, put
the initializing of the array ($company_name = array()) outside of your
loop, just in case.

I used to think that you had to serialize arrays before saving to session,
but apparently that's not the case.  Good to know.

  -- Rob



 Thanks
 --Pushpinder


 On Monday, July 28, 2003, at 03:31 PM, CPT John W. Holmes wrote:

  $details is an array (just like $company_name was). Try to view
  print_r($details); and see what you get.
 
  ---John Holmes...
 
  - Original Message -
  From: Pushpinder Singh Garcha [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Monday, July 28, 2003 3:18 PM
  Subject: [PHP] Store array as Session Variable
 
 
  hello All,
 
I am trying to store an array as a session variable.
 
  while ($row = mysql_fetch_array($result))
  {
  if ( !is_array($company_name) ) $company_name = array();
 array_push($company_name, $row['company']);
 
  // try to register session variable
   $_SESSION['link'] = $company_name;
 
  }
 
 
  Now when I try to access this session variable in another file...I am
  getting a junk value.I am not sure if I am getting this right.
 
  $details = $_SESSION['link'];
echo LINK: .$details.br;
 
 
  Can some one fill me in on this. Appreciate it !  Thanks in advance.
 
  --Pushpinder Singh
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php