[PHP] Re: Sessions nightmare continue...

2004-08-17 Thread Craig Donnelly
Why are you testing if $_POST['submit'] is set are you posting something to
the page??

In the two scripts you posted the code block wont be executed because there
is no post variable
being set.

Try this:

a1.php
==
   ?php

 session_start();
 header(Cache-control: private); // IE 6 Fix.

 $_SESSION[login]=inside;
 session_write_close();
 header(Location: a2.php);
 exit();
?

pre
 ?php print_r($_SESSION); ?
/pre
==

AND

a2.php
==
?php
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(!isset($_SESSION[login])){
  echo(brsession variable NOT set);
 }else{
  echo(brsession variable set);
 }

 echo(brsession ID:  . session_id());
 echo(brsession value:  . $_SESSION[login]);
?

pre
 ?php print_r($_SESSION); ?
/pre
==

Works fine now.

HTH

Craig


Angelo Zanetti [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi all,

 Still no luck with sessions. I have installed an older version: 4.3.1
 and have register_globals=Off

 I have 2 test pages a1.php and a2.php

 All I want to do is register a session variable, set a value for it and
 then in a2.php check that it is still registered and view the session's
 value.

 a1.php:

 ?
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(isset($_POST['Submit']))
 {
 $_SESSION[login]=inside;
 session_write_close();
 header(Location: a2.php);
 exit();
 }
 ?


 I can successfully register the session variable and set the value of
 it on page a1.php but when I go to page a2.php the session variable is
 not set and the value isnt set either.

 a2.php:

 ?
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(!isset($_SESSION[login]))
echo(brsession variable NOT set);
 else
 echo(brsession variable set);

 echo(brsession ID:  . session_id());
 echo(brsession value:  . $_SESSION[login]);

 ?

 I have been trying to get this to work for ages with no luck. I have
 been reading the manual and have googled and cant seem to find the
 problem. if anyone can help that would be great.

 thanks in advance
 Angelo
 
 Disclaimer
 This e-mail transmission contains confidential information,
 which is the property of the sender.
 The information in this e-mail or attachments thereto is
 intended for the attention and use only of the addressee.
 Should you have received this e-mail in error, please delete
 and destroy it and any attachments thereto immediately.
 Under no circumstances will the Cape Technikon or the sender
 of this e-mail be liable to any party for any direct, indirect,
 special or other consequential damages for any use of this e-mail.
 For the detailed e-mail disclaimer please refer to
 http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



[PHP] Re: Sessions nightmare continue...SOLVED

2004-08-17 Thread Angelo Zanetti
Thanks to all that responded, I have finally found the problem:

When I installed PHP again, I kept on modifying the PHP.ini in the
WINNT directory (as specified in the manual) but the PHP.ini that was
being looked up was the 1 in the c:\php directory so I kept on trying
all new things and nothing worked. 

Thanks again. Please remeber so that you dont make the same mistake as
me

Angelo

 Craig Donnelly [EMAIL PROTECTED] 8/17/2004 12:04:42 PM

Why are you testing if $_POST['submit'] is set are you posting
something to
the page??

In the two scripts you posted the code block wont be executed because
there
is no post variable
being set.

Try this:

a1.php
==
   ?php

 session_start();
 header(Cache-control: private); // IE 6 Fix.

 $_SESSION[login]=inside;
 session_write_close();
 header(Location: a2.php);
 exit();
?

pre
 ?php print_r($_SESSION); ?
/pre
==

AND

a2.php
==
?php
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(!isset($_SESSION[login])){
  echo(brsession variable NOT set);
 }else{
  echo(brsession variable set);
 }

 echo(brsession ID:  . session_id());
 echo(brsession value:  . $_SESSION[login]);
?

pre
 ?php print_r($_SESSION); ?
/pre
==

Works fine now.

HTH

Craig


Angelo Zanetti [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi all,

 Still no luck with sessions. I have installed an older version:
4.3.1
 and have register_globals=Off

 I have 2 test pages a1.php and a2.php

 All I want to do is register a session variable, set a value for it
and
 then in a2.php check that it is still registered and view the
session's
 value.

 a1.php:

 ?
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(isset($_POST['Submit']))
 {
 $_SESSION[login]=inside;
 session_write_close();
 header(Location: a2.php);
 exit();
 }
 ?


 I can successfully register the session variable and set the value
of
 it on page a1.php but when I go to page a2.php the session variable
is
 not set and the value isnt set either.

 a2.php:

 ?
 session_start();
 header(Cache-control: private); // IE 6 Fix.

 if(!isset($_SESSION[login]))
echo(brsession variable NOT set);
 else
 echo(brsession variable set);

 echo(brsession ID:  . session_id());
 echo(brsession value:  . $_SESSION[login]);

 ?

 I have been trying to get this to work for ages with no luck. I have
 been reading the manual and have googled and cant seem to find the
 problem. if anyone can help that would be great.

 thanks in advance
 Angelo
 
 Disclaimer
 This e-mail transmission contains confidential information,
 which is the property of the sender.
 The information in this e-mail or attachments thereto is
 intended for the attention and use only of the addressee.
 Should you have received this e-mail in error, please delete
 and destroy it and any attachments thereto immediately.
 Under no circumstances will the Cape Technikon or the sender
 of this e-mail be liable to any party for any direct, indirect,
 special or other consequential damages for any use of this e-mail.
 For the detailed e-mail disclaimer please refer to
 http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



[PHP] Re: sessions nightmare

2002-09-11 Thread lallous

I use JavaScript cookie to accomplish what you're doing in your case:

script
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + = + escape(value) +
  ((expires) ? ; expires= + expires.toGMTString() : ) +
  ((path) ? ; path= + path : ) +
  ((domain) ? ; domain= + domain : ) +
  ((secure) ? ; secure : );
  document.cookie = curCookie;
}

function nav(value)
{
  setCookie('searcheditem', value);
  location.replace('after-search-click.php');
}
/script

now in my search result display i do:
a
href=javascript:nav('?=$search_result['itemid']?')?=$search_result['la
bel']?/a
.
.
then in whatever page I want the search result item, i access it as:
$searchitem (as named in setCookie() call)


good luck,
Elias


Chris [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Greetings,

 I am a new user to php and sessions and for the life of me I
 cannot figure this out

 I want to be able to have a user login (which is completed), they goto a
 search page (completed), and search for a particular item (completed). A
 page will display all the links for the items searched for (completed).
 What I want out of sessions is to when they click on the link for a
 particular item, the item number stay in a session so it can be called
 through out each page they goto. What I have as a base of test code is the
 following (this was taken from someone's example):

 test1.php:

 ?php
 session_start(  );
 session_register(SESSION);

 *** THE FOLLOWING VARIABLE ($retrived_itemno) WOULD NEED TO BE SET ON THE
 *** SEARCH PAGE ***
 $SESSION[item] = $retrived_itemno;

 $test2Url = test2.php?PHPSESSID= . session_id(  );

 ?

 a href=?=$test2Url ?Goto next page/a


 test2.php:

 ?php
 session_start( );
 echo the retrived value equals: $SESSION[item];
 ?



 After you click the hyperlink on test1.php, test2.php will load and the
 session ID is in the URL, but nothing is displayed in the echo for
 $SESSION[item] in test2.php. What is going on?!#!#!$#


 Thanks a million in advance!!
 - Chris





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




[PHP] Re: sessions nightmare

2002-09-11 Thread Erwin

 I want to be able to have a user login (which is completed), they
 goto a search page (completed), and search for a particular item
 (completed). A page will display all the links for the items searched
 for (completed). What I want out of sessions is to when they click on
 the link for a particular item, the item number stay in a session so
 it can be called through out each page they goto. What I have as a
 base of test code is the following (this was taken from someone's
 example):

 test1.php:

 ?php
 session_start(  );
 session_register(SESSION);

 *** THE FOLLOWING VARIABLE ($retrived_itemno) WOULD NEED TO BE SET ON
 THE *** SEARCH PAGE ***
 $SESSION[item] = $retrived_itemno;

 test2.php:

 ?php
 session_start( );
 echo the retrived value equals: $SESSION[item];
 ?

In test2.php:
Your echo line is incorrect. $SESSION[item] is not defined, $SESSION[item]
probably is...but why are you storing an array in a session?

Try using $_SESSION instead of session_register, e.g.:

test1.php:
$SESSION[item] = $retrieved_itemno;
$_SESSION[SESSION] = $SESSION;

test2.php:
$SESSION= $_SESSION[SESSION];
echo The retrieved value equals to  . $SESSION[item];

HTH
Erwin


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




[PHP] Re: sessions nightmare

2002-09-11 Thread Philippe Saladin

Your variable in session is called Item, so session_register(SESSION) is
wrong. It should be session_register(Item). But, as you use directly the
new syntax ($_SESSION) to affect the variable, you don't need
session_register. The variable Item will be automatically registered when
you write $_SESSION[Item] = $retrived_itemno;
And, be careful for the typo : it is $_SESSION[Item] and not
$SESSION[Item] (notice the _ and the ).
Regards,
Philippe

A tip : display what is in your session with this code :
echo 'pre';
print_r($_SESSION);
echo '/pre';



Chris [EMAIL PROTECTED] a écrit dans le message news:
[EMAIL PROTECTED]
 Greetings,

 I am a new user to php and sessions and for the life of me I
 cannot figure this out

 I want to be able to have a user login (which is completed), they goto a
 search page (completed), and search for a particular item (completed). A
 page will display all the links for the items searched for (completed).
 What I want out of sessions is to when they click on the link for a
 particular item, the item number stay in a session so it can be called
 through out each page they goto. What I have as a base of test code is the
 following (this was taken from someone's example):

 test1.php:

 ?php
 session_start(  );
 session_register(SESSION);

 *** THE FOLLOWING VARIABLE ($retrived_itemno) WOULD NEED TO BE SET ON THE
 *** SEARCH PAGE ***
 $SESSION[item] = $retrived_itemno;

 $test2Url = test2.php?PHPSESSID= . session_id(  );

 ?

 a href=?=$test2Url ?Goto next page/a


 test2.php:

 ?php
 session_start( );
 echo the retrived value equals: $SESSION[item];
 ?



 After you click the hyperlink on test1.php, test2.php will load and the
 session ID is in the URL, but nothing is displayed in the echo for
 $SESSION[item] in test2.php. What is going on?!#!#!$#


 Thanks a million in advance!!
 - Chris





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