Jump to content

Session Variables and Persisting across scripts


aussiefly

Recommended Posts

Hi everyone!

 

This is probably a simple fix but because im a newb and still learning its beyond me a bit.

 

I'm currently working on a script that involves members logging in and members areas etc. So i'm clearly using sessions to store user variables and data etc. Now from my main users homepage there is a link to go to a script to change their details like email address etc....lets call it settings.php

 

So they are on members.php and then click a standard href html link to go to settings.php to update their user details. Problem is that when I try to access the session variables on the settings.php page....they are blank...ive tried echoing them out and seeing what comes up and they are empty objects etc...i dont get any errors but they are empty.

 

So i did a bit of reading and found that the settings.php is considered to be a seperate application and therefore the session would be a new unique session and not be able to read the variables from the prior script...members.php

 

So my question is...how do i forward my users to settings.php and get them to update their details with/without those session variables persisting. Is there a way to forward them to that page when they click a link so that it doesnt create a new session?

 

I did try to use a HEADER redirect to send them there upon clicking the button but got the headers already sent error.

 

I suspect there is an easy way to do this and its probably got to do with me using a straight html link to send them to settings.php

 

so any ideas???

Link to comment
Share on other sites

are you saying that they are able to log in and move around the members area and stay logged in but then when you try go to settings.php you can't access the session variables?  If that is the case, is settings.php in a different directory? Session variables can be set to work on only part of the directory tree.:

session_set_cookie_params()

http://www.php.net/manual/en/function.session-set-cookie-params.php

 

use session_get_cookie_params() to get the current session cookie parameters

http://www.php.net/manual/en/function.session-get-cookie-params.php

 

the session variables should be accessable when you just click a regular link to go to another page, that's the point of session variables.

 

Link to comment
Share on other sites

yup when they are logged in on the members section and click a regular link to settings.php which is in the same dir...the session variables appear to be empty. It truly is quite weird....i even have the session start on the new page and everthing in place...but they just appear to not have any values entered

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.