User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 1 Sep 2003, 21:43   #1
SYMM
Love's Sweet Exile
 
SYMM's Avatar
 
Join Date: May 2001
Location: Living on a Stair (Now Sword-less)
Posts: 2,371
SYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better place
PHP sessions and localhost...

I've been playing with PHP again, and tried to do some stuff with authentication and sessions, but (i think) something is not working between my browser (Opera, set to accept all cookies) and localhost.
I've tried with copied examples, and still no look.
I can set $HTTP_SESSION_VARS['example'], but it isn't storing between pages.


If it is an Opera-problem, then telling me how i can stop IE telling me i need to connect to view the page (when i clearly don't...and can't) may help....
__________________
--SYMM--
Ba Ba Ti Ki Di Do
SYMM is offline   Reply With Quote
Unread 1 Sep 2003, 21:50   #2
Add
Registered User
 
Join Date: Feb 2001
Posts: 442
Add will become famous soon enoughAdd will become famous soon enough
are you calling session_start(); at the top of every page?


[edit]

showing us the code of the page(s) in question might help
__________________
Trust in my Instinct
Add is offline   Reply With Quote
Unread 2 Sep 2003, 21:11   #3
SYMM
Love's Sweet Exile
 
SYMM's Avatar
 
Join Date: May 2001
Location: Living on a Stair (Now Sword-less)
Posts: 2,371
SYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better place
Yes, and as i say, i've copied examples off a CD which came with a book (more than one), so i really doubt that is the problem...and the code is on another computer, so not easy to get it here....
__________________
--SYMM--
Ba Ba Ti Ki Di Do
SYMM is offline   Reply With Quote
Unread 3 Sep 2003, 11:54   #4
Add
Registered User
 
Join Date: Feb 2001
Posts: 442
Add will become famous soon enoughAdd will become famous soon enough
Quote:
Originally posted by SYMM
Yes, and as i say, i've copied examples off a CD which came with a book (more than one), so i really doubt that is the problem...and the code is on another computer, so not easy to get it here....
you would be surprised, but no-one can help you with the information you are giving us, there could be a million and one things wrong. we need more information.
__________________
Trust in my Instinct
Add is offline   Reply With Quote
Unread 3 Sep 2003, 19:32   #5
SYMM
Love's Sweet Exile
 
SYMM's Avatar
 
Join Date: May 2001
Location: Living on a Stair (Now Sword-less)
Posts: 2,371
SYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better place
More information? Like what?

The first example:
Code:
<?php
session_start();

$HTTP_SESSION_VARS['example'] = "Hello";

echo "Example = $HTTP_SESSION_VARS['example'] = "Hello";

?>
<a href=page2.php>Next</a>
and page2.php is...
Code:
<?php
session_start();

echo "Example = $HTTP_SESSION_VARS['example'] = "Hello";
?>
__________________
--SYMM--
Ba Ba Ti Ki Di Do
SYMM is offline   Reply With Quote
Unread 4 Sep 2003, 00:54   #6
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Your double quotes don't match and your haven't given your PHP version but you could check there is a "session.use_cookies = 1" in your php.ini.

I found I could get around IE trying to connect by pressing cancel and refreshing a few times. There's an option about trying to connect in the options somewhere.
__________________
#linux
queball is offline   Reply With Quote
Unread 4 Sep 2003, 10:10   #7
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
Quote:
Originally posted by queball
Your double quotes don't match
Exactly.

Also, what error msg are you getting?

Help us to help you!

M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Sep 2003, 11:31   #8
Cicada
p a r r a c i d a
 
Join Date: Apr 2000
Location: #titans
Posts: 511
Cicada is an unknown quantity at this point
Quote:
Originally posted by SYMM
More information? Like what?

The first example:
Code:
<?php
session_start();

$HTTP_SESSION_VARS['example'] = "Hello";

echo "Example = $HTTP_SESSION_VARS['example'] = "Hello";

?>
<a href=page2.php>Next</a>
and page2.php is...
Code:
<?php
session_start();

echo "Example = $HTTP_SESSION_VARS['example'] = "Hello";
?>
this just looks wrong....

the echo bit looks wrong..

and in later versions you can just user $_SESSION['example']
__________________
Cicada || No Warning, No Mercy, No Ambiguity || [Titans] [F.E.A.R]
Cicada is offline   Reply With Quote
Unread 4 Sep 2003, 16:53   #9
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Quote:
Originally posted by SYMM
echo "Example = $HTTP_SESSION_VARS['example']";
You can't do that.
Code:
<?
session_start();
$_SESSION['example'] = "Hello";
$example=$_SESSION['example'];
echo "Example = $example";
?>

<a href="page2.php">Next</a>
Code:
<?
session_start();
$example = $_SESSION['example'];
echo "Example = $example";
?>
Working example at http://www.vd-tools.com/page1.php.

As far as I am aware there are restrictions on where you can use $_SESSION etc so the easy way round it is to always assign all session variables to normal variables at the top of each page.
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 4 Sep 2003, 17:10   #10
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Quote:
Originally posted by Gayle29uk
You can't do that.
Yes you can. Try it and see. His problem is that the first page works and the second doesn't.
Quote:
As far as I am aware there are restrictions on where you can use $_SESSION etc so the easy way round it is to always assign all session variables to normal variables at the top of each page.
$_SESSION is a superglobal and can be accessed anywhere. $HTTP_SESSION_VARS is a global and can be accessed anywhere outside functions, and by using global inside functions too.
http://www.php.net/variables.predefined
queball is offline   Reply With Quote
Unread 4 Sep 2003, 18:16   #11
SYMM
Love's Sweet Exile
 
SYMM's Avatar
 
Join Date: May 2001
Location: Living on a Stair (Now Sword-less)
Posts: 2,371
SYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better place
The quotes are correct on the version on the other computer, simply a typo here.

There's no error message, page2 just reads

Example=


----

In Gayle's example, there's a PHPSESSIONID attached to the URL...my page doesn't have this, should it? And if so what's the line in php.ini to look for.


---
Will try looking for/changing the cookies setting and come back
__________________
--SYMM--
Ba Ba Ti Ki Di Do
SYMM is offline   Reply With Quote
Unread 4 Sep 2003, 19:16   #12
Cicada
p a r r a c i d a
 
Join Date: Apr 2000
Location: #titans
Posts: 511
Cicada is an unknown quantity at this point
Quote:
Originally posted by SYMM


Will try looking for/changing the cookies setting and come back
it's unlikely to be a cookie problem as most browers don't give you the ability to reject session cookies..

session.use_trans_sid is the php ini thing i believe, but you don't need it attached to the url for sessions to work..

if you copy gayles code and execute it on your system, it should work. If it doesn't then you've got an issue with either your browser (unlikely), or some config issue in you php/webserver
__________________
Cicada || No Warning, No Mercy, No Ambiguity || [Titans] [F.E.A.R]
Cicada is offline   Reply With Quote
Unread 4 Sep 2003, 20:03   #13
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Quote:
Originally posted by SYMM
In Gayle's example, there's a PHPSESSIONID attached to the URL...my page doesn't have this, should it? And if so what's the line in php.ini to look for.
????

Nothing extra in the URL when I try it
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 4 Sep 2003, 20:08   #14
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Quote:
Originally posted by queball
Yes you can. Try it and see.
I did, you can't.
Code:
<?
session_start();
$HTTP_SESSION_VARS['example'] = "Hello";
echo "Example = $HTTP_SESSION_VARS['example']";
?>

<a href="page2.php">Next</a>
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/gayle/www/page1b.php on line 4

Unless I'm mistaken with my syntax?
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 4 Sep 2003, 20:29   #15
Add
Registered User
 
Join Date: Feb 2001
Posts: 442
Add will become famous soon enoughAdd will become famous soon enough
Quote:
Originally posted by Gayle29uk
I did, you can't.
Code:
<?
session_start();
$HTTP_SESSION_VARS['example'] = "Hello";
echo "Example = $HTTP_SESSION_VARS['example']";
?>

<a href="page2.php">Next</a>
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/gayle/www/page1b.php on line 4

Unless I'm mistaken with my syntax?

Code:
<?
session_start();
$HTTP_SESSION_VARS['example'] = "Hello";
echo "Example = " . $HTTP_SESSION_VARS['example'];
?>

<a href="page2.php">Next</a>
I don't know why so don't ask.
__________________
Trust in my Instinct
Add is offline   Reply With Quote
Unread 4 Sep 2003, 23:13   #16
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Quote:
Originally posted by Add
Code:
<?
session_start();
$HTTP_SESSION_VARS['example'] = "Hello";
echo "Example = " . $HTTP_SESSION_VARS['example'];
?>

<a href="page2.php">Next</a>
I don't know why so don't ask.
I know that one works

For some reason neither $_SESSION nor $HTTP_SESSION_VARS work directly within an echo (or several other places, PHP doesn't like you using it as a parameter for a function either) though, hence why I assign them all using a foreach
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 4 Sep 2003, 23:59   #17
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Quote:
Originally posted by Gayle29uk

Unless I'm mistaken with my syntax?
it's
echo "Example = $HTTP_SESSION_VARS[example]";
or
echo "Example = ${HTTP_SESSION_VARS['example']}";

I was going on "I can set $HTTP_SESSION_VARS['example'], but it isn't storing between pages." and trying from a shell but forgetting quotes were stripped :-/
queball is offline   Reply With Quote
Unread 5 Sep 2003, 00:49   #18
wu_trax
Registered User
 
Join Date: Jan 2003
Posts: 4,290
wu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet society
call phpinfo() (or whatever that function was) on the 2nd page.
it should somewhere show you with data is stored in your session.
__________________
im not tolerant, i just dont care.
wu_trax is offline   Reply With Quote
Unread 5 Sep 2003, 00:54   #19
wu_trax
Registered User
 
Join Date: Jan 2003
Posts: 4,290
wu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet society
Quote:
Originally posted by Gayle29uk
????

Nothing extra in the URL when I try it
his cookies dont work. in that case php puts the sessionid as an extra attribute to the url, otherwise it uses a cookie (at least i think so, maybe wrong)
__________________
im not tolerant, i just dont care.
wu_trax is offline   Reply With Quote
Unread 5 Sep 2003, 12:32   #20
Add
Registered User
 
Join Date: Feb 2001
Posts: 442
Add will become famous soon enoughAdd will become famous soon enough
Quote:
Originally posted by wu_trax
his cookies dont work. in that case php puts the sessionid as an extra attribute to the url, otherwise it uses a cookie (at least i think so, maybe wrong)
no, i accept all cookies and i still got the phpsessid in the url on gayle's example. most likely her server just puts it there.


SYMM: what php version are you using? Can you post a link to your phpinfo page for us to look at?
__________________
Trust in my Instinct
Add is offline   Reply With Quote
Unread 5 Sep 2003, 19:48   #21
SYMM
Love's Sweet Exile
 
SYMM's Avatar
 
Join Date: May 2001
Location: Living on a Stair (Now Sword-less)
Posts: 2,371
SYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better placeSYMM single handedly makes these forums a better place
4.0.3pl1 on the hosting i use ( http://www.norcliffe.scsuk.net/test/moo.php )
but 4.3.0 on my home computer.

page1.php and page2.php are in that directory (using Gayle's syntax), and still appears not to work (for me and others).


session.use_cookies is set to 1 on my home computer, no access to check on the host.


__________________
--SYMM--
Ba Ba Ti Ki Di Do
SYMM is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 16:04.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018