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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

$_SESSION ??


Go to End


4 Posts   2218 Views

Avatar
DB_steve

Community Member, 7 Posts

6 February 2009 at 1:06am

I have developed an all PHP site frontend with much SQL
operations. One of the needs is to link from the PHP system
to the SS portion as the SS design is really great for handling the
CMS part.

I can not figure out how to send the session data to the SS system.
I am using this method from the frontend

$_SESSION['session_var'] = "Testing123";

and

<form action='sessionTest2.php' method='POST'>

I have the frontend linking well to the SS portion.
But I want to lock down the SS portion so the user has to come thru
the frontend. I figure I can lock it down if I pass the session info to the SS start page,
but how to accomplish this task?

Thanks so very much.
Steve

Avatar
UncleCheese

Forum Moderator, 4102 Posts

6 February 2009 at 3:29am

Sessions are handled by Session::get() and Session::set(), AFAIK.

If you're trying to keep your form secure, however, you want to use the permission class.

    	if(!Permission::check('ADMIN')) {
				Security::permissionFailure($this,
					"You must be logged in to use this form."
				);
    	}

Avatar
DB_steve

Community Member, 7 Posts

6 February 2009 at 5:02am

thanks for the reply.

All well and good, except, I really need an example of how to do this.

Where does one place the code to accomplish the transfer of $_SESSION data?

Do you have a complete example I can study and test?

Once I see the mechanism, I will better understand the process.

Thanks again
Steve

Avatar
david_nash

Community Member, 55 Posts

14 May 2009 at 2:09pm

How'd you go with this Steve?

I'm trying to get my head around SS sessions myself. I believe to get your $_SESSION data, in the controller you can use
Session::start($_SESSION) and it should transfer everything to the Session object.

see http://api.silverstripe.com/default/Session.html#__construct

Is this what you did?