[PAYH] $_SESSION not working now
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- [PAYH] $_SESSION not working now
Re: [PAYH] $_SESSION not working now
12-12-2008 11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I needed to add the SID to my redirect string thus
header("Refresh: 0; url=admin/protected/index.php?".SID);
That's all it was
This now makes sense of what you were saying because SID is PHPSESSID so the code above passes the session id to the receiving page.
I upload these two test pages to prove this point
Example #1 A session example: page1.php
<?php
// page1.php
session_start();
echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
After viewing page1.php, the second page page2.php will magically contain the session data. Read the session reference for information on propagating session ids as it, for example, explains what the constant SID is all about.
Example #2 A session example: page2.php
<?php
// page2.php
session_start();
echo 'Welcome to page #2<br />';
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>
i got this info from http://uk2.php.net/manual/en/function.session-start.php
Thanks very much for all your help and patience Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 12:10 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I wonder why the session cookie isn't being accepted from PAYH. Not blocked client-side? Ideally, it's more secure as a cookie. For my own site on PAYH I set session.use_only_cookies on. Any way, glad it's working via the uri.
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 12:13 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Even though it works now as explained in the post above, each visit to a page in the admin/protected area sends me back to the login page.
Remember, the first lines of code in all pages in the admin area are...
<?php
session_start();
if(!$_SESSION['userisvalid'])
{
header("Refresh: 0; url=../../login.php");
exit();
}
?>
I've tried it with and without the SID on the end of the redirect string but it always sends me back to the login page.
The PHPSESSID is different for each visit
On the live site, once you've logged in you can go in and out of the admin area until you log out?
What do I do now?
Re: [PAYH] $_SESSION not working now
12-12-2008 12:39 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 12:52 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Those two test pages prove that it won't work without putting the SID into the string but just when i thought i had fixed it i get this new problem that once it's gone through the login process and got me in to the admin area, i cant move around because the $_SESSION['userisvalid'] variable is empty and so it sends me back to the login page which then creates a new SID. Vicious cirlce
Still can't get my head round what's different about the two platforms.
Here's some more infor from php.net
A session created with session_start will only be available to pages within the directory tree of the page that first created it.
i.e. If the page that first creates the session is /dir1/dir2/index.php and the user then goes to any page above dir2 (e.g. /dir1/index.php), session_start will create a new session rather than use the existing one.
Don't know if relevent or not
Re: [PAYH] $_SESSION not working now
12-12-2008 1:06 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 1:27 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Done it at home and work now, same result.
It will only work if i include the SID in the redirect but then i've still got this other issue where it keeps returning to the login
It's doin my ed in now
how can i guarantee that i'm not blocking them from plushost?
Re: [PAYH] $_SESSION not working now
12-12-2008 1:45 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
If you're stuck with the uri method, you will need to pass the session id to all subsequent pages explicitly.
Try editing your testpage as echo '<br /><a href="page2.php?PHPSESSID=' . session_id() . '">page 2</a>';
See that now appears in the uri? You could then use javascript to pass that to any subsequent pages - not such a secure method but it should work.
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 2:11 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I wouldn't know how to write a script to set a cookie and park on plushost. I don't know what any of that means.
I've checked my internet options, there are no restrictions on cookies at all.
I still don't see why its different on the two platforms but i know that i cant go live on PAYH. There are so many changes i have to make
[PAYH] $_SESSION PlusNet Staff help required
12-12-2008 2:40 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Is there something fundamentally different about payh plathform that is stopping the $_SESSION variables working?
I've lost 2 days trying to make my exsisting CCGI code work on the new platform.
I've also taken up an awful lot of Gabe's time. See previous thread
Will Plusnet staff please help
Re: [PAYH] $_SESSION not working now
12-12-2008 2:40 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
See test examples under setcookie in the php manual.
You can set session cookies on PAYH. In that respect, there is no difference. Plenty of others, but not that one.
You can see the php settings for sessions via phpinfo:
<?php
phpinfo();
?>
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 3:06 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
it didn't write anything to my cookies
I've done the phpinfo and had a browse at the session stuff. What should i see thats relevent to this issue?
session.use_cookies is on
session.use_only_cookies is off
anything else?
Re: [PAYH] $_SESSION not working now
12-12-2008 3:17 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Gabe
Re: [PAYH] $_SESSION not working now
12-12-2008 3:23 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
EDIT:
Same result in both Gabe
Any help from PlusNet staff yet?
The transistion from ccgi to payh is proving to be very painful
Re: [PAYH] $_SESSION not working now
12-12-2008 3:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
is there an alternative way to acheive what I'm trying to. i.e. user login to a protected area.
I know i can use the new protected directories method of the PAYH platform but I don't like it because you can't build your own login page. You have to go with the popup dialog login box.
I just don't know what to try next
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- [PAYH] $_SESSION not working now