May 24, 2012, 07:10:49 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Mobile users - Our forum is Tapatalk enabled.
http://www.tapatalk.com/
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
PHP session issue
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: PHP session issue (Read 268 times)
samhs
Administrator
Hero Member
Posts: 1713
PHP session issue
«
on:
September 14, 2011, 11:16:30 PM »
Am I being thick?
I set a session on one page:
<?php
session_start();
$_SESSION['test']='Hello';
header("Location: page2.php");
?>
and on page2 I try calling the session variable:
<?php
session_start();
echo($_SESSION['test']);
?>
and i get nothing.
This is on a SiteHQ server, browsing through the "preview site" function (i.e. viewing over SSL, not via the actual domain)
Any ideas?
TIA
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
samhs
Administrator
Hero Member
Posts: 1713
Re: PHP session issue
«
Reply #1 on:
September 14, 2011, 11:27:25 PM »
further info:
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
Dom
Hero Member
Posts: 1681
Taster of pasities. Clanger of both pots AND pans.
Re: PHP session issue
«
Reply #2 on:
September 15, 2011, 10:06:20 AM »
My first suggestion would be to check that it's actually storing the session value in the first place. After you set the session variable to "hello", echo it out to the screen before redirecting to 'page2.php' and just make sure that it's storing the session variable properly in the first place.
It probably is, but you never know.
Logged
Sig edited due to lolling at this
http://img72.imageshack.us/img72/6069/mainphpg2viewcoreh.gif
JasonD
Global Moderator
Hero Member
Posts: 551
Re: PHP session issue
«
Reply #3 on:
September 15, 2011, 10:16:17 AM »
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
Is the browser accepting the session cookie? echo $_COOKIE['PHPSESSID'];
No point echo'ing it before redirecting, that will only prove you can type it the same way twice.
Logged
samhs
Administrator
Hero Member
Posts: 1713
Re: PHP session issue
«
Reply #4 on:
September 15, 2011, 10:31:24 AM »
Notice: Undefined index: PHPSESSID in /var/www/vhosts/etc etc etc
So no, it appears not. Could this be being caused by Plesk's weird temporary URL?
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
samhs
Administrator
Hero Member
Posts: 1713
Re: PHP session issue
«
Reply #5 on:
September 15, 2011, 10:48:50 AM »
yes - it was Plesk to blame somehow - setting up an entry in my hosts file sorted it
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
PHP session issue
Loading...