Solved

session variable - help

Posted on 2016-10-19
5
40 Views
Last Modified: 2016-10-19
Hello guys

When I access my site, I start session and set a session variable that I need to use it in other parts of my site, in other pages.

But when I access the new .php I notice that the session variable doesn't has the value.

Shouldn't the session variable belong to all site?  if so, what can it be happening?

thanks
Alex
0
Comment
Question by:hidrau
  • 2
  • 2
5 Comments
 
LVL 26

Assisted Solution

by:skullnobrains
skullnobrains earned 200 total points
ID: 41849846
you need to run session_start() in ALL pages. my guess is you forgot to.

alternatively if the sessions variables do not work at all, you may have misconfigured the session storage location ( for example configuring apache to use memcache while there is no memcache running ) or possibly are using cookie based sessions while cookies are not enabled or not working for some reason
2
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 300 total points
ID: 41849853
Here is how the PHP session works:
https://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html

If you're doing things that way, then your session should preserve stateful information for all pages of your web site.  Try installing and running the session test  script in the article.  If it fails, please post a link here so we can see the failure in action, thanks.
1
 
LVL 1

Author Comment

by:hidrau
ID: 41850050
Thanks friend.

I'm gonna check this in details and I'll return back to inform where I was doing wrong.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 41850059
One other thing to check because it can fail silently... Make sure that PHP has write permissions to write the session.  You can find the file name by running phpinfo() and looking for session.save_path
1
 
LVL 1

Author Closing Comment

by:hidrau
ID: 41851128
thanks
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now