-1

pirnt_r($_SESSION) not print all value.

But we log in wordpress admin and preview page when we write print_r($_SESSION) they display all session variable with value.

Thank you.

Mark
  • 8,046
  • 15
  • 48
  • 78

3 Answers3

2

Can you show us the whole code?

Probable cause:

  1. try print_r($_SESSION) not pirnt_r($_SESSION);
  2. try to put echo before print_r($_SESSION); as in echo print_r($_SESSION);
Mark
  • 8,046
  • 15
  • 48
  • 78
  • soory its my writing mistack i am use print_r($_SESSION) – Usdad Pravin Jun 24 '13 at 06:27
  • Yes try to put `echo print_r($_SESSION);` – Mark Jun 24 '13 at 06:36
  • i try echo print_r($_SESSION) but nothing. when we work in localhost this print all value in print_r($_SESSION) but when we update in server that this issue genrat. but we login wordpess admin and priview the page that time display all session variable with value – Usdad Pravin Jun 24 '13 at 06:43
  • session wwork fine when we run page but when we rediredt thay page after payment with paypal that time print_r($_session) not print value its means session lost data any idea about that @ Christian Mark – Usdad Pravin Jun 24 '13 at 07:23
  • Of course, because the server of Paypal is different from your WordPress server. You can't store the session variables to other server like Paypal. According to [Where are $_SESSION variables stored?](http://stackoverflow.com/questions/454635/where-are-session-variables-stored), session variables are stored on the Apache server. – Mark Jun 24 '13 at 07:27
  • yes we can write code for store value in session in paypal.php file.paypal.php file is put in my theme directory. after we create a page on wordpress and and this paypal.php file select as a template. we access that all variable in localhost but not in server redirect my site after payment. – Usdad Pravin Jun 24 '13 at 07:31
  • I think for security reasons, all session after redirecting to your site after payment MUST be destroyed. – Mark Jun 24 '13 at 07:48
0

Wordpress doesn't use session's to log their users in, so if you log in at /wp-admin there are no $_SESSION variables set. Wordpress also doesn't call session_start(). This means you have to start the session yourself if you haven't done so already.

You can do this in the following way:

if ( ! session_id() )
    session_start();

If you know the session has not been started already you can use just session_start, like so:

session_start();

If you do this your $_SESSION array should contain the variables you put in it previously.

-2

You can write your question here: https://wordpress.stackexchange.com/ maybe more helpful

Community
  • 1
  • 1
Aldi Unanto
  • 3,626
  • 1
  • 22
  • 30