Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Undefined variable: _SESSION when extending LeftAndMain


Go to End


3002 Views

Avatar
Matthew

Community Member, 5 Posts

29 May 2009 at 10:06pm

Edited: 08/06/2009 6:58am

I am trying to write a podcasting module, and am stuck at, well, the beginning. I started by copy and pasting the subclassing info here: http://doc.silverstripe.com/doku.php?id=leftandmain
<br >
<br >into a blank module folder structure.
<br >
<br >the class causing problems looks like this:
<br >

<br >class Podcaster extends LeftAndMain {
<br >
<br >static $url_segment = 'Podcasts';
<br >static $menu_title = 'Podcasts Admin';
<br >static $menu_priority = 60;
<br >
<br >  
<br >	static $template_path = null; // defaults to (project)/templates/email
<br >	
<br >	static $allowed_actions = array(
<br >	);
<br >
<br >	
<br >	static $url_rule = '/$Action/$ID/$OtherID';
<br >	
<br >  
<br >  
<br >  
<br >  
<br >	/**
<br >	 * Initialisation method called before accessing any functionality that BulkLoaderAdmin has to offer
<br >	 */
<br >	public function init() {
<br >		Requirements::javascript('cms/javascript/MyAdmin.js');
<br >		
<br >		parent::init();
<br >	}
<br > 
<br >	/**
<br >	 * Form that will be shown when we open one of the items
<br >	 */	 
<br >	public function getEditForm($id = null) {
<br >		return new Form($this, "EditForm",
<br >			new FieldSet(
<br >				new ReadonlyField('id #',$id)
<br >			),
<br >			new FieldSet(
<br >				new FormAction('go')
<br >			)
<br >		);
<br >	}
<br >}
<br >

<br >
<br > When i try to build the database i get this:
<br >
<br >
<br >[Notice] Undefined variable: _SESSION
<br >GET /
<br >
<br >Line 120 in /Users/matthewkerr/Sites/vbc2/sapphire/core/control/Director.php
<br >
<br >Source
<br >
<br >111 			@file_get_contents('php://input')
<br >112 		);
<br >113 		
<br >114 		// @todo find better way to extract HTTP headers
<br >115 		if(isset($_SERVER['HTTP_ACCEPT'])) $req->addHeader("Accept", $_SERVER['HTTP_ACCEPT']);
<br >116 		if(isset($_SERVER['CONTENT_TYPE'])) $req->addHeader("Content-Type", $_SERVER['CONTENT_TYPE']);
<br >117 		if(isset($_SERVER['HTTP_REFERER'])) $req->addHeader("Referer", $_SERVER['HTTP_REFERER']);
<br >118 
<br >119 		// Load the session into the controller
<br >120 		$session = new Session($_SESSION);
<br >121 		$result = Director::handleRequest($req, $session);
<br >122 		$session->inst_save();
<br >123 
<br >124 		// Return code for a redirection request
<br >125 		if(is_string($result) && substr($result,0,9) == 'redirect:') {
<br >126 			$response = new HTTPResponse();
<br >Trace
<br >
<br >Director::direct(/) 
<br >Line 122 of main.php
<br >

<br >
<br >I really can't even thing where to start, and i've checked all of the usual causes of problems (cases, php file naming.)
<br >
<br >Can anyone help?
<br >
<br >Thanks.
<br >
<br >Yeah forget it, I'm trying this another way...