View Single Post
  #1 (permalink)  
Old July 1st, 2007, 07:41 AM
mcmahonc mcmahonc is offline
Registered User
 
Join Date: Apr 2007
Location: Dublin, , Ireland.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP Sessions - why do I get a warning notice

Hello there,

I am hoping someone can clear something up about PHP Sessions.

If I want to grab the value of something that is already stored in a session and assign it to a variable as follows.

$user_id=$_SESSION['user_id'];

This only seems to work if a session_start(); statement is called in advance.

session_start();
$user_id=$_SESSION['user_id'];

//user_id will be assigned the value that is stored in the session

The major use of sessions within the application is to maintain the logged in status.

When I call session_start() I get an warning/notice to say that the session has aready been started and as a result the call to session_start(); has been ignored.

If I remove the line however I cannot get anything out of my session.

Does anyone have any ideas?

Regards,

Claire