Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export email from &_SESSION #27

Open
altarifr opened this issue Mar 12, 2014 · 2 comments
Open

Export email from &_SESSION #27

altarifr opened this issue Mar 12, 2014 · 2 comments

Comments

@altarifr
Copy link

Hello all,
I am trying to use the email of the user to send per email some additional information on one of my PHP script.

I am trying to use the session variable to exploit the email without success:

Here what I tried :

$_SESSION['userPieUser'][0]; or $_SESSION['userPieUser']['email']; without success.

When trying to see the content of this table array i got :

Array ( [userPieUser] => loggedInUser Object ( [email] => email88@yahoo.de [hash_pw] => f959274288efa86cded889c8c160e993828b1f8003dee1c8ece9966f6dd4d111c [user_id] => 5 [clean_username] => admin [display_username] => admin [remember_me] => [remember_me_sessid] => d96062c6d42c6f298a2afc7e9196ba3cc532aa0eed4fb1bf190dd5e0a1f69257e ) )

Any help would be very appreciated.
Thanks
Altarifr.

@kyranb
Copy link
Contributor

kyranb commented Mar 12, 2014

First of all, Is there any reason why you cannot use the email that is stored in the database?

Anyway, after the user has logged in, you can access the user's email with: $loggedInUser->email

This is because on login.php, when a username and password match, the object loggedInUser(found in class.user) is stored in the session array:

$_SESSION["userPieUser"] = $loggedInUser;

Take a look at config.php to see how this works as well:

if(isset($_SESSION["userPieUser"]) && is_object($_SESSION["userPieUser"]))
$loggedInUser = $_SESSION["userPieUser"];

Hope that helps :)

@altarifr
Copy link
Author

Indeed it works.
Thanks for your help, that is working as you mentionned.
I did not want back to the database as in the process. the user would login and select few item in his cart (shopping web site). When confirming his cart I wanted to send him an email with his cart content. If the email and other data are in the &_SESSION array I do not see added value to read it from the database.

Please correct me if I am wrong on my approach.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants